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
CipherSuitesPolicy constructor throws PlatformNotSupportedException on Linux with OpenSSL 1.1.1 #61891
According to the documentation, it should be possible to use the CipherSuitesPolicy class on Linux systems with OpenSSL 1.1.1 or higher or macOS. However, when using .NET 6 on Linux with OpenSSL 1.1.1, PlatformNotSupportedException is thrown. The same code works fine when using .NET 5
Unhandled exception. System.PlatformNotSupportedException: CipherSuitesPolicy is not supported on this platform.
at System.Net.Security.CipherSuitesPolicyPal..ctor(IEnumerable`1 allowedCipherSuites)
at System.Net.Security.CipherSuitesPolicy..ctor(IEnumerable`1 allowedCipherSuites)
at csptest.Program.Main() in /home/gth/csptest/Program.cs:line 9
So the method on Ssl class is called sooner than static constructor for given class. None of the logic seems to change in 6.0.
Adding @stephentoub and @janvorli in case they have some more insight to the mystery.
That uses a static field initializer to populate the value. I that runs before the explicit cctor. So this has probably always had an ordering dependency on waking up something from the main crypto codepaths first; just for one reason or another it never came up.
That does work. I'm not sure how much we care about loosing readonly.
We could possibly fix up this particular in different ways (including the C PAL) But I'm wondering if we may have issues with other functions as well where somebody may (indirectly) call some functionality before fist SSL kicks in.
Activity
vcsjones commentedon Nov 21, 2021
Hm, well, I can reproduce it on 21.10 using 6.0-RTM installed by binaries.
wfurt commentedon Nov 21, 2021
There is something wrong with the loading. It works when I modify it as
API_EXISTS(SSL_CTX_set_ciphersuites)returns 0 andSSL_CTX_set_ciphersuites_ptris null with the original code.cc: @bartonjs
bartonjs commentedon Nov 22, 2021
I wonder if the CipherSuitesPolicy ctor functionally depends on CryptoInitializer but doesn't actually cause it to run.
wfurt commentedon Nov 22, 2021
It seems like the problem is ordering. I have two breakpoints and the following lldb/sos fragment is in order.
So the method on Ssl class is called sooner than static constructor for given class. None of the logic seems to change in 6.0.
Adding @stephentoub and @janvorli in case they have some more insight to the mystery.
bartonjs commentedon Nov 22, 2021
runtime/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs
Lines 143 to 146 in e9036b0
That uses a static field initializer to populate the value. I that runs before the explicit cctor. So this has probably always had an ordering dependency on waking up something from the main crypto codepaths first; just for one reason or another it never came up.
wfurt commentedon Nov 22, 2021
I think you are right. The reason why it worked in 5.0 is
so the function pointers were always loaded regardless of
CryptoNative_EnsureLibSslInitializedbeing called.That was removed in #46640.
cc: @VSadov
bartonjs commentedon Nov 22, 2021
So the fix is probably just to delay call the routine
wfurt commentedon Nov 22, 2021
That does work. I'm not sure how much we care about loosing
readonly.We could possibly fix up this particular in different ways (including the C PAL) But I'm wondering if we may have issues with other functions as well where somebody may (indirectly) call some functionality before fist SSL kicks in.
wfurt commentedon Feb 8, 2022
Fixed in 7.0 (main) in PR #62973 and in 6.0.3 in PR #64252.