I'm new to Python but have to build a Websocket API for work. The website of the websockets module says that this code should work for secure websocket connections (https://websockets.readthedocs.io/en/stable/intro.html)
However, I cannot get the provided code to work..
import websockets
import asyncio
import pathlib
import ssl
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_verify_locations(pathlib.Path(__file__).with_name('localhost.pem'))
I get the error:
Traceback (most recent call last):
File "/Applications/Python 3.7/apii.py", line 7, in module> ssl_context.load_verify_locations(pathlib.Path(__ file__).with_name('localhost.pem'))
FileNotFoundError: [Errno 2] No such file or directory
Could you help me out?
PS. I do not get the idea of this ssl_context code at all. Could somebody explain the logic behind it, please?