Skip to content
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

InvalidCastException on constructor #3

Closed
nathannau opened this issue Sep 25, 2017 · 4 comments
Closed

InvalidCastException on constructor #3

nathannau opened this issue Sep 25, 2017 · 4 comments
Assignees

Comments

@nathannau
Copy link

nathannau commented Sep 25, 2017

Hello.

I have :
System.InvalidCastException : Unable to cast object of type 'System.Security.Cryptography.RSACng' to type 'System.Security.Cryptography.RSACryptoServiceProvider'.
at OpenSSL.X509Certificate2Provider.CertificateFromFileProvider..ctor(String certificateText, String privateKeyText, SecureString securePassword)

         var dataCrt = @"-----BEGIN CERTIFICATE-----
         MIIE9DCCA9ygAwIBAgIRAO/GFHEnfG7PfRsqfJE2XCMwDQYJKoZIhvcNAQELBQAw
         ...
         sbLyGg+ZHI2KE9mVzmsgITnzuaD1gXmc
         -----END CERTIFICATE-----";
         var dataKey = @"-----BEGIN PRIVATE KEY-----
         MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC8UIRu1ho6sD+6
         ...
         VCASulQriYsBYxeSBSXVEA==
         -----END PRIVATE KEY-----";
         var provider = new OpenSSL.X509Certificate2Provider.CertificateFromFileProvider(dataCrt,dataKey);
         var cert = provider.Certificate;
         Assert.True(cert.Verify());
         Assert.True(cert.HasPrivateKey);

I'm using dotnet core 2.0

@StefH
Copy link
Owner

StefH commented Sep 26, 2017

How did you create that public / private key ?

@nathannau
Copy link
Author

nathannau commented Sep 26, 2017 via email

@StefH
Copy link
Owner

StefH commented Sep 27, 2017

@nathannau Did you try running your example on .NET 4.5.2 or .NET 4.6 ? Because I guess it's a NetCore issue.

@StefH StefH self-assigned this Oct 8, 2017
@StefH
Copy link
Owner

StefH commented Oct 8, 2017

New versions uploaded to NuGet.

@StefH StefH closed this as completed Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants