The Error
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056) SSL handshake failed on verifying the certificate
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')]
Full traceback (156 lines): https://pastebin.com/xmy4aYcM
Debugging info
I am running on fully updated Raspbian Buster with Python 3.7.3, on a Raspberry Pi 3.
Output of uname -a:
Linux hostname 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
Output of lsb_release -a:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Output of pip freeze:
aiohttp==3.5.4
async-timeout==3.0.1
attrs==19.3.0
certifi==2019.9.11
chardet==3.0.4
discord.py==1.2.4
idna==2.8
multidict==4.5.2
pkg-resources==0.0.0
websockets==6.0
yarl==1.3.0
>>> import os
>>> import ssl
>>> openssl_dir, openssl_cafile = os.path.split(
... ssl.get_default_verify_paths().openssl_cafile)
>>> os.listdir(openssl_dir)
['openssl.cnf', 'private', 'misc', 'certs']
>>> print(os.path.exists(openssl_cafile))
False
What I've tried
All my online searches give one of two suggestions:
- Install
certifiusing pip- I have already installed it, and it does not change anything.
- Run
Install Certificates.commandin the/Applications/Python 3.X/folder- This is Mac specific. In general, all mentions of this error have been on Mac only.
Minimal reproducing example
Create a venv, and install packages
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ca-certificates python3-venv python3-pip
python3 -m venv env
source env/bin/activate
python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel
python3 -m pip install -U discord.py certifi
Open a python3 prompt, and run:
import discord
client = discord.Client()
client.run("token") # error happens here
I do not encounter this same error on my PC running Linux and the same Python version and packages.
Is there a way to either
- Ignore ssl certificate validation checking (like the
--insecureflag on curl), or - Properly install the missing certificates?