As pointed out by others, this problem "is caused by an untrusted SSL certificate". My answer is based on the top-rated answer and this answer.
You can test the certificate using curl
:
curl -vvI https://example.com
If an error returns, you have 3 options:
requests.get('https://example.com', verify=False)
requests.get('https://example.com', verify='/path/to/certfile')
My problem was because I was using only my site's certificate, not the intermediate (a.k.a. chain) certificate.
If you are using Let's Encrypt, you should use the fullchain.pem
file, not cert.pem
.