Pithikos / python-websocket-server

A simple fully working websocket-server in Python with no external dependencies
MIT License
1.13k stars 380 forks source link

WARNING:websocket_server.websocket_server:SSL not available #99

Open gasanaff opened 2 years ago

gasanaff commented 2 years ago

I inserted the key.pem and cert.pem in the same directory with the py script and tried to specify the absolute path and relative path and got the same error. (777 permissions)

_WARNING:websocket_server.websocket_server:SSL not available (are the paths key.pem and cert.pem correct for the key and cert?)_

pendrya commented 2 years ago

I have same error when trying to connect via wss, WARNING:websocket_server.websocket_server:SSL not available (are the paths key.pem and cert.pem correct for the key and cert?)

both cert and key pems are in same folder as the script and 777 permissions

onmahadev commented 2 years ago

i have same error when try start with SSL support

jo24 commented 2 years ago

I also had this problem, but it came from my setup...

tmsk0711 commented 1 year ago

me too.... :(

cbureriu commented 1 year ago

me too. same warning: WARNING:websocket_server.websocket_server:SSL not available (are the paths privkey.pem and cert.pem correct for the key and cert?)

then the exception: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 8: invalid start byte

full exception output: Exception occurred during processing of request from ('x.x.x.x', x) Traceback (most recent call last): File "/usr/lib/python3.9/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python3.9/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/lib/python3.9/dist-packages/websocket_server/websocket_server.py", line 271, in __init__ StreamRequestHandler.__init__(self, socket, addr, server) File "/usr/lib/python3.9/socketserver.py", line 720, in __init__ self.handle() File "/usr/local/lib/python3.9/dist-packages/websocket_server/websocket_server.py", line 282, in handle self.handshake() File "/usr/local/lib/python3.9/dist-packages/websocket_server/websocket_server.py", line 430, in handshake headers = self.read_http_headers() File "/usr/local/lib/python3.9/dist-packages/websocket_server/websocket_server.py", line 418, in read_http_headers http_get = self.rfile.readline().decode().strip() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 8: invalid start byte

cbureriu commented 1 year ago

I figured it out. It wants the full chain. cert='fullchain.pem' <--- instead of 'cert.pem' key='privkey.pem'

594zouying commented 1 year ago

Generated SSL crt and key from the official website of one provider of cloud service, and configured them to the nginx .conf. The ws could be connected from client side.
If private key is used, using the command like openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem. Server: changed the parameter to " server = WebsocketServer(port = PORT,host = HOST,loglevel=logging.INFO,cert='cert.pem',key='cert.pem') ". Client: ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE}). The WS connection is also working by using this way.

mgeilich commented 3 months ago

I have not been able to get this to work (on a Mac). Same symptoms as above. Requests seem to be getting to the server but the server is not able to use the self-signed cert and key files. Has anyone figured this out?

INFO:websocket_server.websocket_server:Listening on port 4567 for clients.. INFO:websocket_server.websocket_server:Starting WebsocketServer on main thread. WARNING:websocket_server.websocket_server:SSL not available (are the paths key.pem and cert.pem correct for the key and cert?)

Exception occurred during processing of request from ('127.0.0.1', 58033) Traceback (most recent call last): File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socketserver.py", line 683, in process_request_thread self.finish_request(request, client_address) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/Users/michael/Library/Python/3.9/lib/python/site-packages/websocket_server/websocket_server.py", line 271, in init StreamRequestHandler.init(self, socket, addr, server) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socketserver.py", line 747, in init self.handle() File "/Users/michael/Library/Python/3.9/lib/python/site-packages/websocket_server/websocket_server.py", line 282, in handle self.handshake() File "/Users/michael/Library/Python/3.9/lib/python/site-packages/websocket_server/websocket_server.py", line 430, in handshake headers = self.read_http_headers() File "/Users/michael/Library/Python/3.9/lib/python/site-packages/websocket_server/websocket_server.py", line 418, in read_http_headers http_get = self.rfile.readline().decode().strip() File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/socket.py", line 704, in readinto return self._sock.recv_into(b) OSError: [Errno 9] Bad file descriptor