How to configure Secure WSS on my WebSocketSharp Server in .Net

Viewed 19

I have this code on my server:

  Public Shared Sub Start(Port As Integer)

            ws = New WebSocketServer(Port, True)

            Dim filename As String = "cert.pfx"
            Dim cert As New Security.Cryptography.X509Certificates.X509Certificate2(filename, "pass123", Security.Cryptography.X509Certificates.X509KeyStorageFlags.MachineKeySet)

            With ws.SslConfiguration
                .ServerCertificate = cert
                .ClientCertificateRequired = False
                .CheckCertificateRevocation = False
                .ClientCertificateValidationCallback = Function() As Boolean
                                                           Return True
                                                       End Function
                .EnabledSslProtocols = Security.Authentication.SslProtocols.Tls12
            End With

            ws.AddWebSocketService(Of GameBehavior)("/Game")
            ws.Start()

        End Sub

The application runs without any errors. But when a client connects via wss, I get this error:

9/1/2022 6:08:54 PM|Fatal|<>c__DisplayClass71_0.b__0:0|System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate

I get no error whatsoever when I start the same application in ws mode (without secure wss).

What am I doing wrong? How to proper configure WSS on WebSocketSharp Server?

0 Answers
Related