diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs index 828af2acfac0ee..9b9329c4413722 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs @@ -80,7 +80,7 @@ private static SslProtocols CalculateEffectiveProtocols(SslAuthenticationOptions { SslProtocols protocols = sslAuthenticationOptions.EnabledSslProtocols; - if (!Interop.Ssl.Tls13Supported) + if (!Interop.Ssl.Capabilities.Tls13Supported) { if (protocols != SslProtocols.None && CipherSuitesPolicyPal.WantsTls13(protocols)) diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs index 1db80064b2c80c..8d1cad3d480fda 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs @@ -149,6 +149,15 @@ internal static partial class Ssl [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetData")] internal static partial int SslSetData(IntPtr ssl, IntPtr data); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Tls13Supported")] + private static partial int Tls13SupportedImpl(); + + internal static class Capabilities + { + // needs separate type (separate static cctor) to be sure OpenSSL is initialized. + internal static readonly bool Tls13Supported = Tls13SupportedImpl() != 0; + } + internal static unsafe int SslSetAlpnProtos(SafeSslHandle ssl, List protocols) { byte[] buffer = ConvertAlpnProtocolListToByteArray(protocols); @@ -190,10 +199,6 @@ internal static byte[] ConvertAlpnProtocolListToByteArray(List allowedCipherSuites) { - if (!Interop.Ssl.Tls13Supported) + if (!Interop.Ssl.Capabilities.Tls13Supported) { throw new PlatformNotSupportedException(SR.net_ssl_ciphersuites_policy_not_supported); }