From: Jeremy Koritzinsky Date: Tue, 14 Sep 2021 23:29:42 +0000 (-0700) Subject: Merge branch 'main' of https://github.com/dotnet/runtime into merge-main X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~12628^2~23^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81293bfc1e59fe54a24d4bc5dc965317cec4e1ec;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Merge branch 'main' of https://github.com/dotnet/runtime into merge-main --- 81293bfc1e59fe54a24d4bc5dc965317cec4e1ec diff --cc NuGet.config index 45ad637,f74e0c4..c665193 --- a/NuGet.config +++ b/NuGet.config @@@ -15,14 -15,13 +15,15 @@@ + + + - - + + diff --cc src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs index 5b3b9d6,f38e947..2e6e72c --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs @@@ -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); @@@ -106,32 -111,32 +111,32 @@@ 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 readCallback, + delegate* unmanaged 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, diff --cc src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs index c31d402,a73de25..a2fdddd --- 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 @@@ -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) { @@@ -84,130 -88,125 +88,124 @@@ [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 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 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 diff --cc src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs index 217f419,e8e208e..674b2a6 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtx.cs @@@ -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 callback, IntPtr arg); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetAlpnSelectCb")] + internal static unsafe partial void SslCtxSetAlpnSelectCb(SafeSslContextHandle ctx, delegate* unmanaged callback, IntPtr arg); - internal static unsafe int SslCtxSetAlpnProtos(SafeSslContextHandle ctx, List protocols) - { - byte[] buffer = ConvertAlpnProtocolListToByteArray(protocols); - fixed (byte* b = buffer) - { - return SslCtxSetAlpnProtos(ctx, (IntPtr)b, buffer.Length); - } - } - - internal static byte[] ConvertAlpnProtocolListToByteArray(List 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; } } } diff --cc src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs index 66b776b,60c8107..364ed6e --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SslCtxOptions.cs @@@ -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 callback); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetVerify")] + internal static unsafe partial void SslCtxSetVerify(SafeSslContextHandle ctx, delegate* unmanaged 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); } } diff --cc src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj index 148a85e,1139f2e..0fd7e9a --- a/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.Watcher/tests/System.IO.FileSystem.Watcher.Tests.csproj @@@ -1,10 -1,8 +1,10 @@@ + true true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-FreeBSD - true + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-FreeBSD + true + true diff --cc src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs index 4e1fead,c040dae..7ac8ecd --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.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)