Erreur MacOS SSL: CERTIFICATE_VERIFY_FAILED
Vous essayez de lancer un script Python mais vous vous retrouvez avec cette erreur :
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
Pas de panique, il suffit de trouver un fichier sur votre disque dur et de lâexĂ©cuter.
La solution pour rĂ©soudre lâerreur SSL: CERTIFICATE_VERIFY_FAILED
est dâaller dans votre dossier Python /Applications/Python 3.xx/
et de double-cliquer sur le fichier Install Certificates.command
.
Ce dossier se trouve directement dans votre disque dur âMacintosh HDâ puis /Applications
et vous devriez trouver Python 3.xx/
.
Lâerreur SSLCertVerificationError complĂšte
Voici le message dâerreur ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
complet :
Traceback (most recent call last):
File "lib/python3.12/site-packages/aiohttp/connector.py", line 1080, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1126, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1159, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/sslproto.py", line 575, in _on_handshake_complete
raise handshake_exc
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/sslproto.py", line 557, in _do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 917, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
Par exemple, si le certificat nâest pas installĂ© quand vous faites un bot discord en Python avec discord.py, vous pourriez avoir cette erreur :
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "bot_discord/main.py", line 13, in <module>
client.run(token=token)
File "lib/python3.12/site-packages/discord/client.py", line 869, in run
asyncio.run(runner())
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 664, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/discord/client.py", line 858, in runner
await self.start(token, reconnect=reconnect)
File "lib/python3.12/site-packages/discord/client.py", line 786, in start
await self.login(token)
File "lib/python3.12/site-packages/discord/client.py", line 620, in login
data = await self.http.static_login(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/discord/http.py", line 816, in static_login
data = await self.request(Route('GET', '/users/@me'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/discord/http.py", line 638, in request
async with self.__session.request(method, url, **kwargs) as response:
File "lib/python3.12/site-packages/aiohttp/client.py", line 1353, in __aenter__
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/aiohttp/connector.py", line 975, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/aiohttp/connector.py", line 1350, in _create_direct_connection
raise last_exc
File "lib/python3.12/site-packages/aiohttp/connector.py", line 1319, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "lib/python3.12/site-packages/aiohttp/connector.py", line 1082, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')]
Je m'appelle Thomas, et je code depuis plus de 20 ans. Depuis ma sortie de la premiĂšre promotion de l'Ăcole 42, j'ai conçu et dĂ©veloppĂ© des centaines d'applications et de sites web. Sur ce blog, je partage avec vous les stratĂ©gies les plus efficaces pour maĂźtriser l'art de coder et progresser rapidement.