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 }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Guys, I have been facing multiple challenges with getting the ManagedOpenSsl to work with .Net Core. I downloaded ManagedOpenSsl.NetCore from nuget package.
My end goal is to create a .pfx file from certificate PEM and private key. In the below code, ocert.KeyPair.PrivateKey is the certificate private key and ocert.CertificatePem is the certificate PEM.
ManagedOpenSsl.NetCore.Core.BIO key_bio = new ManagedOpenSsl.NetCore.Core.BIO(ocert.KeyPair.PrivateKey);
ManagedOpenSsl.NetCore.Core.BIO cert_bio = new ManagedOpenSsl.NetCore.Core.BIO(ocert.CertificatePem);
ManagedOpenSsl.NetCore.Crypto.CryptoKey key = ManagedOpenSsl.NetCore.Crypto.CryptoKey.FromPrivateKey(ocert.KeyPair.PrivateKey, "xxxxx");
ManagedOpenSsl.NetCore.X509.X509Certificate cert = new ManagedOpenSsl.NetCore.X509.X509Certificate(cert_bio);
ManagedOpenSsl.NetCore.Core.Stack<ManagedOpenSsl.NetCore.X509.X509Certificate> hmm = new ManagedOpenSsl.NetCore.Core.Stack<ManagedOpenSsl.NetCore.X509.X509Certificate>();
var pfx = new ManagedOpenSsl.NetCore.X509.PKCS12(password, key, cert, hmm); // <--
ManagedOpenSsl.NetCore.X509.X509Certificate certpfx = pfx.Certificate;
I'm getting error {System.TypeInitializationException: The type initializer for 'ManagedOpenSsl.NetCore.Core.Native' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at ManagedOpenSsl.NetCore.Core.Native.SSLeay() at ManagedOpenSsl.NetCore.Core.Version.get_Library() at ManagedOpenSsl.NetCore.Core.Native..cctor() --- End of inner exception stack trace - in the line of code `ManagedOpenSsl.NetCore.Core.BIO key_bio = new ManagedOpenSsl.NetCore.Core.BIO(ocert.KeyPair.PrivateKey);
I have set the Platform Target to "Any CPU", still the issue occurs. Also any implementation on how to save the pfx.Certificate to a specific folder in .pfx format ? Any help will be appreciated. Been struggling with this issue for a while now.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Guys, I have been facing multiple challenges with getting the ManagedOpenSsl to work with .Net Core. I downloaded ManagedOpenSsl.NetCore from nuget package.
My end goal is to create a .pfx file from certificate PEM and private key. In the below code,
ocert.KeyPair.PrivateKey
is the certificate private key andocert.CertificatePem
is the certificate PEM.I'm getting error {System.TypeInitializationException: The type initializer for 'ManagedOpenSsl.NetCore.Core.Native' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at ManagedOpenSsl.NetCore.Core.Native.SSLeay() at ManagedOpenSsl.NetCore.Core.Version.get_Library() at ManagedOpenSsl.NetCore.Core.Native..cctor() --- End of inner exception stack trace - in the line of code `ManagedOpenSsl.NetCore.Core.BIO key_bio = new ManagedOpenSsl.NetCore.Core.BIO(ocert.KeyPair.PrivateKey);
I have set the Platform Target to "Any CPU", still the issue occurs. Also any implementation on how to save the
pfx.Certificate
to a specific folder in .pfx format ? Any help will be appreciated. Been struggling with this issue for a while now.The text was updated successfully, but these errors were encountered: