You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Security.Cryptography.Native.Openssl should not load OpenSSL eagerly on macOS #46771
OpenSSL is optional on macOS - it's needed only for AES-GCM/CCM encryption.
However we have __attribute__((constructor)) static void InitializeOpenSSLShim() which aborts if OpenSSL is not found.
As a result, when System.Security.Cryptography.Native.Openssl is statically linked in a single-file scenario, every app will probe for OpenSSL and fail if not found.
We need to either delay-load on first use or invoke initialization explicitly from managed code.
My understanding is that CryptoKit only has Swift bindings, no Objective C bindings. I found references to being able to call into "Swift-only" things from Objective C using some sort of Xcode-generated header, but nothing talking about how to do it outside of Xcode or what the calling conventions would look like for instance functions.
If someone can figure out how to call it from the Apple crypto shim, then sure!
That function is in System.Security.Cryptography.Native.Apple, which doesn't link to OpenSSL.
On macOS both shims can be used. System.Security.Cryptography.Native.Apple is the only one used in the majority of programs that need any crypto. System.Security.Cryptography.Native.OpenSsl gets loaded when the AesGcm or AesCcm types are used, or any of the types whose name explicitly ends in "OpenSsl", (e.g. RSAOpenSsl). I don't really expect that anyone is using the *OpenSsl types from macOS, we might be able to drop support for them (from macOS) in 6 if we have reasons.
Right - the problem is not InitializeAppleCryptoSslShim, it is the InitializeOpenSSLShim
Both have __attribute__((constructor)), so I got confused. Initially I thought both functions cause the trouble.
Only InitializeOpenSSLShim aborts if the library is not found.
Activity
am11 commentedon Jan 8, 2021
Related #46076.
like libgdiplus
runtime/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs
Line 29 in 1d9e50c
would be great!
EgorBo commentedon Jan 9, 2021
BTW, can we use https://developer.apple.com/documentation/cryptokit on mac? it should support AES-GCM/CCM so we can drop this OpenSSL requirement completely on macOS.
We only need to link System.Native.Security.Apple against Cryptokit framework and write a small wrapper in ObjC. Example: https://github.com/dotnet/runtime/blob/master/src/libraries/Native/Unix/System.Native/pal_log.m
cc @bartonjs
bartonjs commentedon Jan 11, 2021
My understanding is that CryptoKit only has Swift bindings, no Objective C bindings. I found references to being able to call into "Swift-only" things from Objective C using some sort of Xcode-generated header, but nothing talking about how to do it outside of Xcode or what the calling conventions would look like for instance functions.
If someone can figure out how to call it from the Apple crypto shim, then sure!
bartonjs commentedon Jan 11, 2021
That function is in System.Security.Cryptography.Native.Apple, which doesn't link to OpenSSL.
On macOS both shims can be used. System.Security.Cryptography.Native.Apple is the only one used in the majority of programs that need any crypto. System.Security.Cryptography.Native.OpenSsl gets loaded when the AesGcm or AesCcm types are used, or any of the types whose name explicitly ends in "OpenSsl", (e.g. RSAOpenSsl). I don't really expect that anyone is using the *OpenSsl types from macOS, we might be able to drop support for them (from macOS) in 6 if we have reasons.
VSadov commentedon Jan 11, 2021
Right - the problem is not
InitializeAppleCryptoSslShim, it is theInitializeOpenSSLShimBoth have
__attribute__((constructor)), so I got confused. Initially I thought both functions cause the trouble.Only
InitializeOpenSSLShimaborts if the library is not found.VSadov commentedon Jan 13, 2021
This was fixed in #46640