# SSLCertVerificationError using python SDK

**URL:** https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999
**Category:** Alpaca Integration Applications
**Created:** [September 30, 2021, 11:23pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999 "2021-09-30T23:23:28Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![dryhops](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dryhops](https://forum.alpaca.markets/u/dryhops)
#### Post date: [September 30, 2021, 11:23pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/1 "2021-09-30T23:23:28Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

### Author: ![dryhops](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dryhops](https://forum.alpaca.markets/u/dryhops)
#### Post date: [September 30, 2021, 11:38pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/2 "2021-09-30T23:38:49Z")

</div>

I should add that I’m using the paper trade URL. Thanks for your time.

---

<div class="post-metadata">

### Author: ![deg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/deg/32/3126_2.png) [@deg](https://forum.alpaca.markets/u/deg)
#### Post date: [October 4, 2021, 10:56pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/3 "2021-10-04T22:56:15Z")

</div>

Seeing the same issue. Haven’t found any useful responses on how to fix.

---

<div class="post-metadata">

### Author: ![gabor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/gabor/32/2038_2.png) [@gabor](https://forum.alpaca.markets/u/gabor)
#### Post date: [October 5, 2021, 7:45am UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/4 "2021-10-05T07:45:21Z")

</div>

> **[Slack is where the future works](https://alpaca-community.slack.com/?redir=%2Farchives%2FCEL9HCSN4%2Fp1633087234137100)**
>
> Slack is a new way to communicate with your team. It’s faster, better organized, and more secure than email.

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!

See also: [Resources for Certificate Chaining Help - Let's Encrypt](https://letsencrypt.org/2021/10/01/cert-chaining-help.html)

---

<div class="post-metadata">

### Author: ![kellytmcnallan](https://avatars.discourse-cdn.com/v4/letter/k/7ea924/32.png) [@kellytmcnallan](https://forum.alpaca.markets/u/kellytmcnallan)
#### Post date: [October 5, 2021, 3:32pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/5 "2021-10-05T15:32:34Z")

</div>

Thank you! I am back up and running. Much appreciated.

---

<div class="post-metadata">

### Author: ![deg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/deg/32/3126_2.png) [@deg](https://forum.alpaca.markets/u/deg)
#### Post date: [October 7, 2021, 3:47pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/6 "2021-10-07T15:47:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![satejchaudhary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/satejchaudhary/32/3308_2.png) [@satejchaudhary](https://forum.alpaca.markets/u/satejchaudhary)
#### Post date: [November 16, 2021, 10:55pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/7 "2021-11-16T22:55:46Z")

</div>

hi @deg - I followed your steps. located the certi SSL file by running  
import certifi  
print(certifi.where())

And deleted the DST Root CA X3 certificate using a text editor. Still get the same issue. Any thoughts?

---

<div class="post-metadata">

### Author: ![deg](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/deg/32/3126_2.png) [@deg](https://forum.alpaca.markets/u/deg)
#### Post date: [November 17, 2021, 12:04am UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/8 "2021-11-17T00:04:13Z")

</div>

Hi @satejchaudhary – what was the location of the DST cert you deleted? Was it the certifi cert, or one of the local DST certs?

---

<div class="post-metadata">

### Author: ![satejchaudhary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/satejchaudhary/32/3308_2.png) [@satejchaudhary](https://forum.alpaca.markets/u/satejchaudhary)
#### Post date: [November 17, 2021, 1:00am UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/9 "2021-11-17T01:00:50Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Hiro](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Hiro](https://forum.alpaca.markets/u/Hiro)
#### Post date: [December 12, 2021, 8:57pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/10 "2021-12-12T20:57:30Z")

</div>

Hello @satejchaudhary,

I am also new on this issue and experiencing the same error. Did you get a solution for this by now?

Thank you!

---

<div class="post-metadata">

### Author: ![satejchaudhary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/satejchaudhary/32/3308_2.png) [@satejchaudhary](https://forum.alpaca.markets/u/satejchaudhary)
#### Post date: [December 13, 2021, 2:16am UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/11 "2021-12-13T02:16:19Z")

</div>

Hi

The following Fix worked for me

1. Downgraded to Python 3.8

2. Downloaded the Lets Encrypt R3 certificate in .pem format from this website [Chain of Trust - Let's Encrypt](https://letsencrypt.org/certificates/)

3. Renamed the extension from .pem to .cer . On doing so windows automatically changed the icon to look like a certificate

4. Double Clicked on the certificate. Windows opened up a window

5. Click on Install Certificate and the following dialogue box opens up

First install for Current User

Then for Local Machine

---

<div class="post-metadata">

### Author: ![rgutin](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@rgutin](https://forum.alpaca.markets/u/rgutin)
#### Post date: [December 27, 2021, 6:49pm UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/12 "2021-12-27T18:49:28Z")

</div>

Hey, how do I get access to the Slack. Having this issue right now!

---

<div class="post-metadata">

### Author: ![miajones](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/miajones/32/7242_2.png) [@miajones](https://forum.alpaca.markets/u/miajones)
#### Post date: [May 27, 2025, 9:41am UTC](https://forum.alpaca.markets/t/sslcertverificationerror-using-python-sdk/6999/14 "2025-05-27T09:41:05Z")

</div>

While this can quickly resolve SSL errors, it’s important to note that it compromises the security of your application by allowing potential man-in-the-middle attacks. occurs when you request a remote URL that does not provide a trusted SSL certificate. The easiest way to fix this issue is to disable SSL verification for that [Shiraz Wine](https://wines123.blogspot.com/2025/05/shiraz-wine-comprehensive-overview-one.html) particular web address by passing in as an argument to the method calls. SSL certificates. The SSLError exception is rarely encountered in web scraping but the easiest way to fix it is to simply.
