Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't handshake with WSS #6

Open
CodeSpartan opened this issue Apr 3, 2019 · 4 comments
Open

Can't handshake with WSS #6

CodeSpartan opened this issue Apr 3, 2019 · 4 comments

Comments

@CodeSpartan
Copy link

CodeSpartan commented Apr 3, 2019

Error log:

WS closed with code: TlsHandshakeFailure
UnityEngine.Debug:Log(Object)
<>c:<Start>b__1_2(WebSocketCloseCode) (at Assets/Scripts/WebSocketDemo.cs:40)
HybridWebSocket.WebSocket:<.ctor>b__13_3(Object, CloseEventArgs) (at Assets/Plugins/WebSocket.cs:495)
WebSocketSharp.Ext:Emit(EventHandler`1, Object, CloseEventArgs) (at E:/Repos/WebsocketsSharp/websocket-sharp/Ext.cs:1269)

In sta/websocket-sharp, this is fixed by adding this line:
ws.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

Is it possible to fix this in this library? I could add this line myself in the constructor, I'm just not sure what's the correct way to treat it.

@salmansaleem32
Copy link

Hi, any update on this issue ?

@Swaelo
Copy link

Swaelo commented Jun 21, 2019

Hi, any update on this issue ?

The fix is in CodeSpartans comment, owner of the repo is inactive so pull request hasnt been accepted

@salmansaleem32
Copy link

Hi @Swaelo
That error has been resolved. Now browser is giving me this error.
WebSocket connection to "domain" failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

Any suggestions ?

@KudryX2
Copy link

KudryX2 commented Mar 17, 2021

The solution CodeSpartan found worked for me too.

@salmansaleem32 you need to create the server with a certificate, you can do it with openssl.
In my case im using typescript with node

const Fs = require('fs');
const Https = require('https');
const WebSocketServer = require('ws').Server;

const httpsServer = Https.createServer({
  cert: Fs.readFileSync('cert/cert.pem'),
  key: Fs.readFileSync('cert/key.pem'),
  passphrase : 'certPassword'
});

const wss = new WebSocketServer({server: httpsServer});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants