Reputation: 110
Here is what I am trying to run
ws = websocket.WebSocketApp('wss://open.rocket.chat/sockjs/websocket',
header=["User-Agent: MyProgram", "x-custom: header"],
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close,
on_ping=on_ping
)
ws.run_forever()
When I run the code I get this error from the on_error function:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)
I am running the code on macOS, python3.7
the requirements include:
websocket==0.2.1
websocket-client==0.58.0
The solution I tried before was adding the headers above, it worked in a Windows and linux environment, but not in a macOS.
Another thing I tried is to turn off the ssl verification like so export PYTHONHTTPSVERIFY=0
, this did not work as well.
Can you please explain the reason behind this error, and why is it inconsistent? Sometimes it works sometimes it does not! I want to understand the reason to be able to solve it for good. Any suggestions?
Upvotes: 0
Views: 1260
Reputation: 110
I found the answer for MacOS.
All you need to do is to navigate to Applications/Python 3.x
and run this file Install Certificates.command
Upvotes: 1