Skip to content

Try to Secure WebSocket: Unknow error while processing the certificate #144

@Pablo-Jean

Description

@Pablo-Jean

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#:

//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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions