statianzo / Fleck

C# Websocket Implementation
MIT License
2.28k stars 583 forks source link

SSL: No credentials available in the security package #307

Open ChristianKernDev opened 3 years ago

ChristianKernDev commented 3 years ago

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?

AdrianBathurst commented 3 years ago

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

ChristianKernDev commented 3 years ago

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.