-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-System.SecurityquestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.
Milestone
Description
Description
Hi there, we are seeing this error when using dotnet 7 to load certificates.
Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:020000AB:rsa routines::invalid keypair
at Interop.Crypto.DecodePkcs8PrivateKey(ReadOnlySpan`1 source, EvpAlgorithmId algorithmId)
at System.Security.Cryptography.RSAOpenSsl.ImportParameters(RSAParameters parameters)
at System.Security.Cryptography.RSA.ImportEncryptedPkcs8PrivateKey(ReadOnlySpan`1 password, ReadOnlySpan`1 source, Int32& bytesRead)
at System.Security.Cryptography.PemKeyHelpers.ImportEncryptedPem[TPass](ReadOnlySpan`1 input, ReadOnlySpan`1 password, ImportEncryptedKeyAction`1 importAction)
at System.Security.Cryptography.X509Certificates.X509Certificate2.ExtractKeyFromEncryptedPem[TAlg](ReadOnlySpan`1 keyPem, ReadOnlySpan`1 password, Func`1 factory, Func`2 import)
at System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromEncryptedPem(ReadOnlySpan`1 certPem, ReadOnlySpan`1 keyPem, ReadOnlySpan`1 password)
at SimpleWebServer.Program.Main(String[] args) in /app/SimpleWebServer/Program.cs:line 17
at SimpleWebServer.Program.<Main>(String[] args)
I have created two simple applications: one is using C#, the other is using C++ to demonstrate this issue. Both applications are using same certificates. Could you pls help us to figure out how to solve this issue? Thanks.
dotnet.tar.gz
Reproduction Steps
For C# application:
- Unzip the file.
- cd ./dotnet-issue/SimpleWebServer
- ./simplewebserver build
- docker run -d --name simplewebserver --publish 443:10001 simplewebserver
- docker logs simplewebserver.
Should be able to see the issue.
For C++ application:
- Unzip the file.
- cd ./dotnet-issue/SimpleWebServer
- ./simplewebserver build-cpp
- docker run -d --name simplewebservercpp --publish 443:8080 simplewebservercpp
- docker logs simplewebservercpp.
The application is running without issue.
Expected behavior
Dotnet application should be able to load the certificates.
Actual behavior
Dotnet application could not load the certificates.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.SecurityquestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.