Merge branch 'main' of https://github.com/dotnet/runtime into merge-main
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Tue, 14 Sep 2021 23:29:42 +0000 (16:29 -0700)
committerJeremy Koritzinsky <jekoritz@microsoft.com>
Tue, 14 Sep 2021 23:29:42 +0000 (16:29 -0700)
31 files changed:
1  2 
Directory.Build.targets
NuGet.config
eng/Versions.props
src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs
src/libraries/Common/tests/Common.Tests.csproj
src/libraries/System.Console/src/System.Console.csproj
src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj
src/libraries/System.IO.Compression.Brotli/src/System.IO.Compression.Brotli.csproj
src/libraries/System.IO.Compression/src/System.IO.Compression.csproj
src/libraries/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj
src/libraries/System.IO.FileSystem.Watcher/src/System.IO.FileSystem.Watcher.csproj
src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj
src/libraries/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj
src/libraries/System.Net.Http/src/System.Net.Http.csproj
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV4Statistics.cs
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV6Statistics.cs
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdTcpStatistics.cs
src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
src/libraries/System.Net.Security/src/System.Net.Security.csproj
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs
src/libraries/System.Security.Cryptography.OpenSsl/src/System.Security.Cryptography.OpenSsl.csproj
src/libraries/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj
src/libraries/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj

Simple merge
diff --cc NuGet.config
      <add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
      <add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
      <add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
+     <add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
+     <add key="dotnet7-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7-transport/nuget/v3/index.json" />
+     <!-- TODO: Remove dotnet6 feeds when dependencies publish into dotnet7 feeds: https://github.com/dotnet/runtime/issues/57716. -->
      <add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
      <add key="dotnet6-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6-transport/nuget/v3/index.json" />
-     <!-- Used for dotnet pack task -->
-     <add key="nuget-build" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/nuget-build/nuget/v3/index.json" />
      <!-- Used for the Rich Navigation indexing task -->
      <add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
 +    <!-- Used for DllImportGenerator -->
 +    <add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
    </packageSources>
    <disabledPackageSources>
      <clear />
Simple merge
@@@ -57,11 -57,16 +57,16 @@@ internal static partial class Intero
              Renegotiate,
          }
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslCreateContext")]
 -        internal static extern System.Net.SafeSslHandle SslCreateContext(int isServer);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslCreateContext")]
 +        internal static partial System.Net.SafeSslHandle SslCreateContext(int isServer);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetConnection")]
 -        internal static extern int SslSetConnection(
++        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetConnection")]
++        internal static partial int SslSetConnection(
+             SafeSslHandle sslHandle,
+             IntPtr sslConnection);
 -        [DllImport(Interop.Libraries.AppleCryptoNative)]
 -        private static extern int AppleCryptoNative_SslSetMinProtocolVersion(
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)]
 +        private static partial int AppleCryptoNative_SslSetMinProtocolVersion(
              SafeSslHandle sslHandle,
              SslProtocols minProtocolId);
  
              int cbTargetName,
              out int osStatus);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SSLSetALPNProtocols")]
 -        internal static extern int SSLSetALPNProtocols(SafeSslHandle ctx, SafeCreateHandle cfProtocolsRefs, out int osStatus);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SSLSetALPNProtocols")]
 +        internal static partial int SSLSetALPNProtocols(SafeSslHandle ctx, SafeCreateHandle cfProtocolsRefs, out int osStatus);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetAlpnSelected")]
 -        internal static extern int SslGetAlpnSelected(SafeSslHandle ssl, out SafeCFDataHandle protocol);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslGetAlpnSelected")]
 +        internal static partial int SslGetAlpnSelected(SafeSslHandle ssl, out SafeCFDataHandle protocol);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslHandshake")]
 -        internal static extern PAL_TlsHandshakeState SslHandshake(SafeSslHandle sslHandle);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslHandshake")]
 +        internal static partial PAL_TlsHandshakeState SslHandshake(SafeSslHandle sslHandle);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative)]
 -        private static extern int AppleCryptoNative_SslSetAcceptClientCert(SafeSslHandle sslHandle);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)]
 +        private static partial int AppleCryptoNative_SslSetAcceptClientCert(SafeSslHandle sslHandle);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetIoCallbacks")]
 -        internal static extern unsafe int SslSetIoCallbacks(
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslSetIoCallbacks")]
-         internal static partial int SslSetIoCallbacks(
++        internal static unsafe partial int SslSetIoCallbacks(
              SafeSslHandle sslHandle,
-             SSLReadFunc readCallback,
-             SSLWriteFunc writeCallback);
+             delegate* unmanaged<IntPtr, byte*, void**, int> readCallback,
+             delegate* unmanaged<IntPtr, byte*, void**, int> writeCallback);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslWrite")]
 -        internal static extern unsafe PAL_TlsIo SslWrite(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslWrite")]
 +        internal static unsafe partial PAL_TlsIo SslWrite(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslRead")]
 -        internal static extern unsafe PAL_TlsIo SslRead(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten);
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative, EntryPoint = "AppleCryptoNative_SslRead")]
 +        internal static unsafe partial PAL_TlsIo SslRead(SafeSslHandle sslHandle, byte* writeFrom, int count, out int bytesWritten);
  
 -        [DllImport(Interop.Libraries.AppleCryptoNative)]
 -        private static extern int AppleCryptoNative_SslIsHostnameMatch(
 +        [GeneratedDllImport(Interop.Libraries.AppleCryptoNative)]
 +        private static partial int AppleCryptoNative_SslIsHostnameMatch(
              SafeSslHandle handle,
              SafeCreateHandle cfHostname,
              SafeCFDateHandle cfValidTime,
@@@ -38,21 -39,24 +39,24 @@@ internal static partial class Intero
          [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslDestroy")]
          internal static extern void SslDestroy(IntPtr ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetConnectState")]
 -        internal static extern void SslSetConnectState(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetConnectState")]
 +        internal static partial void SslSetConnectState(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetAcceptState")]
 -        internal static extern void SslSetAcceptState(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetAcceptState")]
 +        internal static partial void SslSetAcceptState(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetAlpnProtos")]
 -        internal static extern int SslSetAlpnProtos(SafeSslHandle ssl, IntPtr protos, int len);
++        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetAlpnProtos")]
++        internal static partial int SslSetAlpnProtos(SafeSslHandle ssl, IntPtr protos, int len);
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetVersion")]
 -        internal static extern IntPtr SslGetVersion(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetVersion")]
 +        internal static partial IntPtr SslGetVersion(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetTlsExtHostName")]
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetTlsExtHostName", CharSet = CharSet.Ansi)]
          [return: MarshalAs(UnmanagedType.Bool)]
 -        internal static extern bool SslSetTlsExtHostName(SafeSslHandle ssl, string host);
 +        internal static partial bool SslSetTlsExtHostName(SafeSslHandle ssl, string host);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGet0AlpnSelected")]
 -        internal static extern void SslGetAlpnSelected(SafeSslHandle ssl, out IntPtr protocol, out int len);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGet0AlpnSelected")]
 +        internal static partial void SslGetAlpnSelected(SafeSslHandle ssl, out IntPtr protocol, out int len);
  
          internal static byte[]? SslGetAlpnSelected(SafeSslHandle ssl)
          {
          [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslShutdown")]
          internal static extern int SslShutdown(IntPtr ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslShutdown")]
 -        internal static extern int SslShutdown(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslShutdown")]
 +        internal static partial int SslShutdown(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetBio")]
 -        internal static extern void SslSetBio(SafeSslHandle ssl, SafeBioHandle rbio, SafeBioHandle wbio);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetBio")]
 +        internal static partial void SslSetBio(SafeSslHandle ssl, SafeBioHandle rbio, SafeBioHandle wbio);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslDoHandshake", SetLastError = true)]
 -        internal static extern int SslDoHandshake(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslDoHandshake", SetLastError = true)]
 +        internal static partial int SslDoHandshake(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslStateOK")]
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_IsSslStateOK")]
          [return: MarshalAs(UnmanagedType.Bool)]
 -        internal static extern bool IsSslStateOK(SafeSslHandle ssl);
 +        internal static partial bool IsSslStateOK(SafeSslHandle ssl);
  
          // NOTE: this is just an (unsafe) overload to the BioWrite method from Interop.Bio.cs.
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")]
 -        internal static extern unsafe int BioWrite(SafeBioHandle b, byte* data, int len);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")]
 +        internal static unsafe partial int BioWrite(SafeBioHandle b, byte* data, int len);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")]
 -        internal static extern int BioWrite(SafeBioHandle b, ref byte data, int len);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_BioWrite")]
 +        internal static partial int BioWrite(SafeBioHandle b, ref byte data, int len);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertificate")]
 -        internal static extern SafeX509Handle SslGetPeerCertificate(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertificate")]
 +        internal static partial SafeX509Handle SslGetPeerCertificate(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertChain")]
 -        internal static extern SafeSharedX509StackHandle SslGetPeerCertChain(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerCertChain")]
 +        internal static partial SafeSharedX509StackHandle SslGetPeerCertChain(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerFinished")]
 -        internal static extern int SslGetPeerFinished(SafeSslHandle ssl, IntPtr buf, int count);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetPeerFinished")]
 +        internal static partial int SslGetPeerFinished(SafeSslHandle ssl, IntPtr buf, int count);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetFinished")]
 -        internal static extern int SslGetFinished(SafeSslHandle ssl, IntPtr buf, int count);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetFinished")]
 +        internal static partial int SslGetFinished(SafeSslHandle ssl, IntPtr buf, int count);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSessionReused")]
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSessionReused")]
          [return: MarshalAs(UnmanagedType.Bool)]
 -        internal static extern bool SslSessionReused(SafeSslHandle ssl);
 +        internal static partial bool SslSessionReused(SafeSslHandle ssl);
  
-         [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslAddExtraChainCert")]
-         internal static partial bool SslAddExtraChainCert(SafeSslHandle ssl, SafeX509Handle x509);
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetClientCAList")]
 -        private static extern SafeSharedX509NameStackHandle SslGetClientCAList_private(SafeSslHandle ssl);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetClientCAList")]
 +        private static partial SafeSharedX509NameStackHandle SslGetClientCAList_private(SafeSslHandle ssl);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetCurrentCipherId")]
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetCurrentCipherId")]
          [return: MarshalAs(UnmanagedType.Bool)]
 -        internal static extern bool SslGetCurrentCipherId(SafeSslHandle ssl, out int cipherId);
 +        internal static partial bool SslGetCurrentCipherId(SafeSslHandle ssl, out int cipherId);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOpenSslCipherSuiteName")]
 -        private static extern IntPtr GetOpenSslCipherSuiteName(SafeSslHandle ssl, int cipherSuite, out int isTls12OrLower);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOpenSslCipherSuiteName")]
 +        private static partial IntPtr GetOpenSslCipherSuiteName(SafeSslHandle ssl, int cipherSuite, out int isTls12OrLower);
  
-         internal static string? GetOpenSslCipherSuiteName(SafeSslHandle ssl, TlsCipherSuite cipherSuite, out bool isTls12OrLower)
-         {
-             string? ret = Marshal.PtrToStringAnsi(GetOpenSslCipherSuiteName(ssl, (int)cipherSuite, out int isTls12OrLowerInt));
-             isTls12OrLower = isTls12OrLowerInt != 0;
-             return ret;
-         }
+         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetCiphers")]
+         internal static extern unsafe bool SslSetCiphers(SafeSslHandle ssl, byte* cipherList, byte* cipherSuites);
  
-         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Tls13Supported")]
-         private static extern int Tls13SupportedImpl();
-         internal static readonly bool Tls13Supported = Tls13SupportedImpl() != 0;
+         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetVerifyPeer")]
+         internal static extern void SslSetVerifyPeer(SafeSslHandle ssl);
  
-         internal static SafeSharedX509NameStackHandle SslGetClientCAList(SafeSslHandle ssl)
-         {
-             Crypto.CheckValidOpenSslHandle(ssl);
+         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslGetData")]
+         internal static extern IntPtr SslGetData(IntPtr ssl);
  
-             SafeSharedX509NameStackHandle handle = SslGetClientCAList_private(ssl);
+         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetData")]
+         internal static extern int SslSetData(SafeSslHandle ssl, IntPtr data);
  
-             if (!handle.IsInvalid)
+         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslSetData")]
+         internal static extern int SslSetData(IntPtr ssl, IntPtr data);
+         internal static unsafe int SslSetAlpnProtos(SafeSslHandle ssl, List<SslApplicationProtocol> protocols)
+         {
+             byte[] buffer = ConvertAlpnProtocolListToByteArray(protocols);
+             fixed (byte* b = buffer)
              {
-                 handle.SetParent(ssl);
+                 return SslSetAlpnProtos(ssl, (IntPtr)b, buffer.Length);
              }
-             return handle;
          }
  
-         internal static bool AddExtraChainCertificates(SafeSslHandle sslContext, X509Chain chain)
+         internal static byte[] ConvertAlpnProtocolListToByteArray(List<SslApplicationProtocol> applicationProtocols)
          {
-             Debug.Assert(chain != null, "X509Chain should not be null");
-             Debug.Assert(chain.ChainElements.Count > 0, "chain.Build should have already been called");
-             // If the last certificate is a root certificate, don't send it. PartialChain means the last cert wasn't a root.
-             int stop = chain.ChainElements.Count - 1;
-             foreach (X509ChainStatus s in chain.ChainStatus)
+             int protocolSize = 0;
+             foreach (SslApplicationProtocol protocol in applicationProtocols)
              {
-                 if ((s.Status & X509ChainStatusFlags.PartialChain) != 0)
+                 if (protocol.Protocol.Length == 0 || protocol.Protocol.Length > byte.MaxValue)
                  {
-                     stop++;
-                     break;
+                     throw new ArgumentException(SR.net_ssl_app_protocols_invalid, nameof(applicationProtocols));
                  }
+                 protocolSize += protocol.Protocol.Length + 1;
              }
  
-             // Don't include the first item (the cert whose private key we have)
-             for (int i = 1; i < stop; i++)
+             byte[] buffer = new byte[protocolSize];
+             var offset = 0;
+             foreach (SslApplicationProtocol protocol in applicationProtocols)
              {
-                 SafeX509Handle dupCertHandle = Crypto.X509UpRef(chain.ChainElements[i].Certificate!.Handle);
-                 Crypto.CheckValidOpenSslHandle(dupCertHandle);
-                 if (!SslAddExtraChainCert(sslContext, dupCertHandle))
-                 {
-                     Crypto.ErrClearError();
-                     dupCertHandle.Dispose(); // we still own the safe handle; clean it up
-                     return false;
-                 }
-                 dupCertHandle.SetHandleAsInvalid(); // ownership has been transferred to sslHandle; do not free via this safe handle
+                 buffer[offset++] = (byte)(protocol.Protocol.Length);
+                 protocol.Protocol.Span.CopyTo(buffer.AsSpan(offset));
+                 offset += protocol.Protocol.Length;
              }
  
-             return true;
+             return buffer;
          }
  
-         internal static bool AddExtraChainCertificates(SafeSslHandle sslContext, X509Certificate2[] chain)
+         internal static string? GetOpenSslCipherSuiteName(SafeSslHandle ssl, TlsCipherSuite cipherSuite, out bool isTls12OrLower)
          {
-             // send pre-computed list of intermediates.
-             for (int i = 0; i < chain.Length; i++)
+             string? ret = Marshal.PtrToStringAnsi(GetOpenSslCipherSuiteName(ssl, (int)cipherSuite, out int isTls12OrLowerInt));
+             isTls12OrLower = isTls12OrLowerInt != 0;
+             return ret;
+         }
+         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Tls13Supported")]
 -        [return: MarshalAs(UnmanagedType.Bool)]
 -        private static extern bool Tls13SupportedImpl();
 -        internal static readonly bool Tls13Supported = Tls13SupportedImpl();
++        private static extern int Tls13SupportedImpl();
++        internal static readonly bool Tls13Supported = Tls13SupportedImpl() != 0;
+         internal static SafeSharedX509NameStackHandle SslGetClientCAList(SafeSslHandle ssl)
+         {
+             Crypto.CheckValidOpenSslHandle(ssl);
+             SafeSharedX509NameStackHandle handle = SslGetClientCAList_private(ssl);
+             if (!handle.IsInvalid)
              {
-                 SafeX509Handle dupCertHandle = Crypto.X509UpRef(chain[i].Handle);
-                 Crypto.CheckValidOpenSslHandle(dupCertHandle);
-                 if (!SslAddExtraChainCert(sslContext, dupCertHandle))
-                 {
-                     Crypto.ErrClearError();
-                     dupCertHandle.Dispose(); // we still own the safe handle; clean it up
-                     return false;
-                 }
-                 dupCertHandle.SetHandleAsInvalid(); // ownership has been transferred to sslHandle; do not free via this safe handle
+                 handle.SetParent(ssl);
              }
  
-             return true;
+             return handle;
          }
  
          internal static class SslMethods
@@@ -18,44 -19,26 +19,26 @@@ internal static partial class Intero
          [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxDestroy")]
          internal static extern void SslCtxDestroy(IntPtr ctx);
  
-         [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnProtos")]
-         internal static partial int SslCtxSetAlpnProtos(SafeSslContextHandle ctx, IntPtr protos, int len);
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnSelectCb")]
 -        internal static extern unsafe void SslCtxSetAlpnSelectCb(SafeSslContextHandle ctx, delegate* unmanaged<IntPtr, byte**, byte*, byte*, uint, IntPtr, int> callback, IntPtr arg);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnSelectCb")]
 +        internal static unsafe partial void SslCtxSetAlpnSelectCb(SafeSslContextHandle ctx, delegate* unmanaged<IntPtr, byte**, byte*, byte*, uint, IntPtr, int> callback, IntPtr arg);
  
-         internal static unsafe int SslCtxSetAlpnProtos(SafeSslContextHandle ctx, List<SslApplicationProtocol> protocols)
-         {
-             byte[] buffer = ConvertAlpnProtocolListToByteArray(protocols);
-             fixed (byte* b = buffer)
-             {
-                 return SslCtxSetAlpnProtos(ctx, (IntPtr)b, buffer.Length);
-             }
-         }
-         internal static byte[] ConvertAlpnProtocolListToByteArray(List<SslApplicationProtocol> applicationProtocols)
+         internal static bool AddExtraChainCertificates(SafeSslContextHandle ctx, X509Certificate2[] chain)
          {
-             int protocolSize = 0;
-             foreach (SslApplicationProtocol protocol in applicationProtocols)
+             // send pre-computed list of intermediates.
+             for (int i = 0; i < chain.Length; i++)
              {
-                 if (protocol.Protocol.Length == 0 || protocol.Protocol.Length > byte.MaxValue)
+                 SafeX509Handle dupCertHandle = Crypto.X509UpRef(chain[i].Handle);
+                 Crypto.CheckValidOpenSslHandle(dupCertHandle);
+                 if (!SslCtxAddExtraChainCert(ctx, dupCertHandle))
                  {
-                     throw new ArgumentException(SR.net_ssl_app_protocols_invalid, nameof(applicationProtocols));
+                     Crypto.ErrClearError();
+                     dupCertHandle.Dispose(); // we still own the safe handle; clean it up
+                     return false;
                  }
-                 protocolSize += protocol.Protocol.Length + 1;
+                 dupCertHandle.SetHandleAsInvalid(); // ownership has been transferred to sslHandle; do not free via this safe handle
              }
  
-             byte[] buffer = new byte[protocolSize];
-             var offset = 0;
-             foreach (SslApplicationProtocol protocol in applicationProtocols)
-             {
-                 buffer[offset++] = (byte)(protocol.Protocol.Length);
-                 protocol.Protocol.Span.CopyTo(buffer.AsSpan(offset));
-                 offset += protocol.Protocol.Length;
-             }
-             return buffer;
+             return true;
          }
      }
  }
@@@ -11,25 -11,28 +11,28 @@@ internal static partial class Intero
  {
      internal static partial class Ssl
      {
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxAddExtraChainCert")]
 -        internal static extern bool SslCtxAddExtraChainCert(SafeSslContextHandle ctx, SafeX509Handle x509);
++        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxAddExtraChainCert")]
++        internal static partial bool SslCtxAddExtraChainCert(SafeSslContextHandle ctx, SafeX509Handle x509);
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUseCertificate")]
 -        internal static extern int SslCtxUseCertificate(SafeSslContextHandle ctx, SafeX509Handle certPtr);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUseCertificate")]
 +        internal static partial int SslCtxUseCertificate(SafeSslContextHandle ctx, SafeX509Handle certPtr);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUsePrivateKey")]
 -        internal static extern int SslCtxUsePrivateKey(SafeSslContextHandle ctx, SafeEvpPKeyHandle keyPtr);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxUsePrivateKey")]
 +        internal static partial int SslCtxUsePrivateKey(SafeSslContextHandle ctx, SafeEvpPKeyHandle keyPtr);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxCheckPrivateKey")]
 -        internal static extern int SslCtxCheckPrivateKey(SafeSslContextHandle ctx);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxCheckPrivateKey")]
 +        internal static partial int SslCtxCheckPrivateKey(SafeSslContextHandle ctx);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetQuietShutdown")]
 -        internal static extern void SslCtxSetQuietShutdown(SafeSslContextHandle ctx);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetQuietShutdown")]
 +        internal static partial void SslCtxSetQuietShutdown(SafeSslContextHandle ctx);
  
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetVerify")]
 -        internal static extern unsafe void SslCtxSetVerify(SafeSslContextHandle ctx, delegate* unmanaged<int, IntPtr, int> callback);
 +        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetVerify")]
 +        internal static unsafe partial void SslCtxSetVerify(SafeSslContextHandle ctx, delegate* unmanaged<int, IntPtr, int> callback);
  
-         [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetCiphers")]
-         internal static unsafe partial bool SetCiphers(SafeSslContextHandle ctx, byte* cipherList, byte* cipherSuites);
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetCiphers")]
 -        internal static extern unsafe bool SslCtxSetCiphers(SafeSslContextHandle ctx, byte* cipherList, byte* cipherSuites);
++        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetCiphers")]
++        internal static unsafe partial bool SslCtxSetCiphers(SafeSslContextHandle ctx, byte* cipherList, byte* cipherSuites);
  
-         [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SetEncryptionPolicy")]
 -        [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetEncryptionPolicy")]
 -        internal static extern bool SetEncryptionPolicy(SafeSslContextHandle ctx, EncryptionPolicy policy);
++        [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetEncryptionPolicy")]
 +        internal static partial bool SetEncryptionPolicy(SafeSslContextHandle ctx, EncryptionPolicy policy);
      }
  }
@@@ -1,10 -1,8 +1,10 @@@
  <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
 +    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
      <IncludeRemoteExecutor>true</IncludeRemoteExecutor>
-     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-FreeBSD</TargetFrameworks>
-     <IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI>
+     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-FreeBSD</TargetFrameworks>
+     <IgnoreForCI Condition="'$(TargetOS)' == 'Browser' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOSSimulator' or '$(TargetOS)' == 'tvOS'">true</IgnoreForCI>
 +    <EnableDllImportGenerator>true</EnableDllImportGenerator>
    </PropertyGroup>
    <ItemGroup>
      <Compile Include="AssemblyInfo.cs" />
@@@ -53,18 -53,10 +53,15 @@@ namespace Syste
  
          internal const string NewLineConst = "\r\n";
  
-         public static int SystemPageSize
+         private static int GetSystemPageSize()
          {
-             get
 -            Interop.Kernel32.GetSystemInfo(out Interop.Kernel32.SYSTEM_INFO info);
++            Interop.Kernel32.SYSTEM_INFO info;
++            unsafe
 +            {
-                 Interop.Kernel32.SYSTEM_INFO info;
-                 unsafe
-                 {
-                     Interop.Kernel32.GetSystemInfo(&info);
-                 }
-                 return info.dwPageSize;
++                Interop.Kernel32.GetSystemInfo(&info);
 +            }
++
+             return info.dwPageSize;
          }
  
          private static string ExpandEnvironmentVariablesCore(string name)