Fleck icon indicating copy to clipboard operation
Fleck copied to clipboard

SSL: No credentials available in the security package

Open ChristianKernDev opened this issue 4 years ago • 2 comments

I try to use SSL for my WebSocket connection and therefore i use this setup:

var server = new WebSocketServer("wss://0.0.0.0:8181");
var config = BuildConfig();
server.Certificate = X509Certificate2.CreateFromPemFile("fullchain.pem","privkey.pem");

Everything seems fine log says: Using default TLS 1.0 security protocol.

The problem is, that as soon as a client tries to connect an exception is thrown: System.ComponentModel.Win32Exception (0x8009030E): No credentials available in the security package.

I use .NET 5.0, is there any known fix for this?

ChristianKernDev avatar Jan 26 '21 01:01 ChristianKernDev

Might have to use .pfx certificate file. var certificate = new X509Certificate2("path-to-certificate.pfx", "certificate-password");

AdrianBathurst avatar Jan 26 '21 14:01 AdrianBathurst

Yes that fixed it indeed. I wonder if there is a way to make it work with .pem certificates, because i use Certbot to autoamtically recreate the certificates for my domain and now i have to manually convert it to a pfx cert each time a new certificate is generated.

ChristianKernDev avatar Jan 26 '21 17:01 ChristianKernDev