Skip to content

Commit 28b0c70

Browse files
Restore ServicePointManager SSL callback bridge for .NET 10 (#1275)
Replace #if !NET10_0_OR_GREATER guards with #pragma warning disable SYSLIB0014 so that ServicePointManager.ServerCertificateValidationCallback is read and applied to SocketsHttpHandler.SslOptions in all target frameworks, including .NET 10. Without this bridge, apps relying on that callback to handle self-signed or name-mismatched certificates would fail SSL handshake after migrating to .NET 10. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7700101 commit 28b0c70

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,9 @@ private static HttpClient GetHttpClientInstance(Uri URI, int timeout, ArrayList
207207

208208
private static string HttpClientInstanceIdentifier(string proxyHost, int proxyPort, List<string> fileCertificateCollection, int timeout)
209209
{
210-
#if !NET10_0_OR_GREATER
210+
#pragma warning disable SYSLIB0014
211211
bool defaultSslOptions = ServicePointManager.ServerCertificateValidationCallback == null;
212-
#else
213-
bool defaultSslOptions = true;
214-
#endif
212+
#pragma warning restore SYSLIB0014
215213
if (string.IsNullOrEmpty(proxyHost) && CollectionUtils.IsNullOrEmpty(fileCertificateCollection) && timeout== DEFAULT_TIMEOUT && defaultSslOptions)
216214
{
217215
return string.Empty;
@@ -281,15 +279,15 @@ private static SocketsHttpHandler GetHandler(Uri URI, ArrayList authCollection,
281279

282280
private static void SetSslOptions(SocketsHttpHandler handler)
283281
{
284-
#if !NET10_0_OR_GREATER
282+
#pragma warning disable SYSLIB0014
285283
if (ServicePointManager.ServerCertificateValidationCallback != null)
286284
{
287285
handler.SslOptions = new SslClientAuthenticationOptions
288286
{
289287
RemoteCertificateValidationCallback = ServicePointManager.ServerCertificateValidationCallback
290288
};
291289
}
292-
#endif
290+
#pragma warning restore SYSLIB0014
293291
}
294292
#else
295293
[SecuritySafeCritical]

dotnet/src/dotnetframework/GxMail/Exchange/CertificateCallback.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace GeneXus.Mail.Exchange
55
{
66
public static class CertificateCallback
77
{
8-
#if !NET10_0_OR_GREATER
8+
#pragma warning disable SYSLIB0014
99
static CertificateCallback()
1010
{
1111
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
1212
}
13-
#endif
13+
#pragma warning restore SYSLIB0014
1414

1515
public static void Initialize()
1616
{

0 commit comments

Comments
 (0)