简体   繁体   中英

SSL certificate unknown error when connecting to HTTP Tornado server

In my application, I am trying to have a python tornado server communicate with a javascript html page through websockets. I was able to get the connection to work using an un-encrypted ws connection but when I tried to implement the solution on this post:

How to use secure websocket (wss) in Tornado

I get the error:

WARNING:tornado.general:SSL Error on 10 ('::1', 57020, 0, 0): [SSL: SSLV3_ALERT_CERTIFICATE_UNKNOWN] sslv3 alert certificate unknown (_ssl.c:727)

I'm using a self signed certificate and trying to get this working on localhost before I put this onto the real server. I also made sure to change the client code to use wss instead of ws when connecting.

How do I modify my javascript code in the webpage environment so that I can connect to the server even though it is using self signed certificates?

Yes, the fact that your certificates are self-signed is the problem. You can pass validate_cert=False to websocket_connect like this:

ws_req = HTTPRequest("wss://127.0.0.1:8080/ws", validate_cert=False)
ws = await websocket_connect(ws_req)

( full example here )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM