Import Certificate Error - WeOnlyDo Discussion board

Import Certificate Error (wodWebServer / wodWebServer.NET)

by Danny, Tuesday, December 20, 2022, 17:17 (492 days ago)
edited by Danny, Tuesday, December 20, 2022, 17:22

Hi there
wodWebServer.NET

SSL server example works fine with the provided certificate:

cert.Import(AppPath() + "\\certificate.pfx", "weonlydo", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable);
web1.Certificate = cert;

any other certificate (self signed o standard) fails importing Private key with a inner exception 'System.Security.Cryptography.CryptographicException',
so cert.PrivateKey is null and the server won't start.

I tried with using powershell cmdlet, import export from computer certificate store, CreateCertificate API c#, but without luck.

How did you generate the sample certificate?


Thanks
Danny

Import Certificate Error

by Jasmine, Wednesday, December 21, 2022, 21:23 (491 days ago) @ Danny

Hi Danny.

I just tried, for a test, with a certificate from selfsigned.org, works like a charm. I had following code and it works correctly with our SSL sample:


            System.Security.Cryptography.X509Certificates.X509Certificate2 cert = new System.Security.Cryptography.X509Certificates.X509Certificate2();

            cert.Import(AppPath() + "\\localhost.com.pfx", "password", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable);

            web1.Certificate = cert;
            web1.Secure = true;
            web1.SecureMethod = System.Security.Authentication.SslProtocols.Tls13;
            web1.Start();

Import Certificate Error

by Danny, Thursday, December 22, 2022, 08:05 (491 days ago) @ Jasmine

Thanks Jasmine
it works.

Danny

Hi Danny.

I just tried, for a test, with a certificate from selfsigned.org, works like a charm. I had following code and it works correctly with our SSL sample:


System.Security.Cryptography.X509Certificates.X509Certificate2 cert = new System.Security.Cryptography.X509Certificates.X509Certificate2();

cert.Import(AppPath() + "\\localhost.com.pfx", "password", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable);

web1.Certificate = cert;
web1.Secure = true;
web1.SecureMethod = System.Security.Authentication.SslProtocols.Tls13;
web1.Start();