I'm trying to get real time bitcoin price data from the Bitstamp Websocket v2.0 API. Where can I get the certificate if needed? If download of the certificate is automatic, how can I make sure that it is possible for python to verify the received certificate?
The documentation on the Bitstamp website is rather scarce on this matter. Here's a quote from Bitstamp api documentation:
"Once you open a connection via websocket handshake (using HTTP upgrade header), you can subscribe to desired channels."
Bitstamp api docs: https://www.bitstamp.net/websocket/v2/
Tried searching in websockets documentation: https://websockets.readthedocs.io/en/stable/
I have looked into websockets and ssl. Now I know a bit about the handshake but still after much trying and searching I can't figure out what to do.
import asyncio
import websockets
async def bitstamp_ticker():
async with websockets.connect(
'wss://ws.bitstamp.net', ssl=True) as websocket:
pass
asyncio.get_event_loop().run_until_complete(bitstamp_ticker())
From what I understand in the websocket documentation adding ssl=True should be enough to establish a secure connection. But it seems that maybe the bitstamp certificate is not recognized by a Certificate Authority built into Python 3.6. and this is why the error occurs?
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)