I'm using the WebSocketListener lib, it's very good, works fine when the scheme is ws://. But the server won't work when register for Secure WebSocket.
Whats happens is:
I start the server, well configured, with a certificate in .pfx format, associeted the private key.
The server starts without error. But when the client try to connect, I receive an exception with the message:
"Unknown error while processing the certificate"
The code in C#:
//generate cancellation Token
CancellationTokenSource cancellation = new CancellationTokenSource();
var endpoint = new IPEndPoint(IPAddress.Any, porta);
var rfc6455 = new WebSocketFactoryRfc6455();
var options = new WebSocketListenerOptions();
if (File.Exists(server_Config.CertificatePath))
{
THREAD_MOD("Certificado carregado");
cert = new X509Certificate2(server_Config.CertificatePath, server_Config.CertPassword);
}
else
{
THREAD_MOD("Certificado ausente");
}
if (cert != null)
{
WebSocketSecureConnectionExtension tls = new WebSocketSecureConnectionExtension(cert);
server.ConnectionExtensions.RegisterExtension(tls);
THREAD_MOD("Certificado registrado no wss://");
certificate_str = cert.ToString();
button_check_cert.Enabled = true;
}
else
{
THREAD_MOD("Falha ao gerar/carregar certificado");
}
server.StartAsync(cancellation.Token);
task = AcceptWebSocketClientsAsync(server, cancellation.Token);
Sorry if I'm disturbing, cut it's been days since I start to try to use the wss:// scheme.
You better handle the certificate and secure connection through nginx and then proxy-pass your connection to the app.
There is even a free certificate service from letsencrypt available.
Hello,
I'm using the WebSocketListener lib, it's very good, works fine when the scheme is
ws://
. But the server won't work when register for Secure WebSocket.Whats happens is: I start the server, well configured, with a certificate in
.pfx
format, associeted the private key. The server starts without error. But when the client try to connect, I receive an exception with the message:"Unknown error while processing the certificate"
The code in C#:
Sorry if I'm disturbing, cut it's been days since I start to try to use the
wss://
scheme.