Secure Websocket over SSL connection authentication issue C#

  • Thread starter Thread starter Coder92
  • Start date Start date
C

Coder92

Guest
I am working on a secure WebSocket implementation using the X509Certificate2 class and sslStream. While AuthenticateAsServer is called it gives the error of This operation is not allowed on a security context that has already been authenticated and on the client, I am getting error Error during WebSocket handshake: net:: ERR_SSL_PROTOCOL_ERROR. Below is my code for server implementation:

Loading Certificate:
serverCertificate = X509Certificate.CreateFromCertFile("Certificate.cer");

Authentication: getting error on this line
sslStream.AuthenticateAsServer(serverCertificate, false, System.Security.Authentication.SslProtocols.Tls12, false);


If the above method of AuthenticateAsServer is removed then got error of authentication required on the following line:
await sslStream.ReadAsync(buffer, 0, buffer.Length, cts.Token);


Continue reading...
 
Back
Top