-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.PlatformNotSupportedException' occurred in System.Security.Cryptography.Algorithms.dll #27276
Comments
Trying to look into this (so I can learn a bit more), but haven't found anything definitive yet. I see the ECDiffieHellmanSecurityTransforms will throw this exception when calling ExportExplicitParameters. I see this function being called in plenty of tests that I assume have run on a Linux machine before. I'm assuming that there is another class that finishes this implementation that I am not seeing. I see there is a factory object that should be doing this, but I am missing some symbols to look further. Working on getting this project to build, and then I will dig deeper if nobody else has. |
To create a copy of a key you should use the |
is there something we can do to make the exception more helpful? |
@danmosemsft I'm not sure that a resource string of "This method is only available on Windows" would really help. If we ever made the Roslyn analyzer to warn about methods like this, and this didn't already get added, we should add it there. But I don't know what precedent we have other than just throw a default PNSE. |
@bartonjs I guess I was thinking that the message could potentially say something like "To create a copy of a key you should use the ExportParameters() method to obtain the rich ECParameters object; which can then be sent through ECDiffieHellman.Create(ECParameters) and the PublicKey property of that object be read to get back a second instance of ECDiffieHellmanPublicKey." (I don't know) |
Main problem was to get serialized output from (public) key.... |
@furoraest The problem is that the subset of algorithms and parameters supported on Windows and Unix (using OpenSSL) is different. The format of the output BLOB returned by It would be possible to implement certain subset, but it's likely not worth it since the code for loading the byte array and re-creating it uses You may be interested in the new APIs in #22020, particularly |
Thank You for hints, it helped me develop platform-independent code and get it done without CNG. |
From @furoraest on August 30, 2018 17:44
Hope this is the right repo for this problem:
When trying to export from ECDiffieHellman to ECDiffieHellmanPublicKey.ToByteArray() the exception rises:
Exception has occurred: CLR/System.PlatformNotSupportedException
An exception of type 'System.PlatformNotSupportedException' occurred in System.Security.Cryptography.Algorithms.dll but was not handled in user code: 'Operation is not supported on this platform.' at System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanOpenSslPublicKey.ToByteArray()
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.1.401/
Host (useful for support):
Version: 2.1.3
Commit: 124038c13e
.NET Core SDKs installed:
2.1.401 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
When looking at the data stucture the value of ECDH key is presented as type:
Microsoft.Win32.SafeHandles.SafeEcKeyHandle
Perhaps this is the problem?
Method description lists net core 2.0 and 2.1
https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.ecdiffiehellmanpublickey.tobytearray?view=netframework-4.7.2
Best regards
Copied from original issue: dotnet/coreclr#19767
The text was updated successfully, but these errors were encountered: