A few days ago, I created a functional python program that was successfully fetching historical data with AsyncRest in the python alpaca_trade_api SDK.
However, when trying to run the same script today, I encountered the following error for every ticker I try to get data for:
Got an error: Cannot connect to host data.alpaca.markets:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1125)')]
Manually checking the endpoint, the certificate seems fine. I tried regenerating my API key, but the problem persists. Any suggestions on how to get this working again?
I have installed the latest python 3.9 on my windows 10 to reproduce the problem and I experienced the same issue. I had to delete the intermediate certificate (Issued to: R3, Issued by: DST Root CA X3) from the windows CA list. It helped!
This was indeed the issue. Note that if you’re using certifi (and I was) you’ll need to delete the DST Root CA X3 certificate from the certifi SSL file.
And, final note, Windows 10 may actually reinstall the DST cert automatically. If this is happening to you, the fastest fix is to pip install certifi and modify the certifi SSL file.
Hi @deg
The location was C:\Users\chaud\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\certifi\cacert.pem
I am fairly new to this stuff. Would appreciate if you could elaborate on share exact steps to get to the right file. Thanks!