Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to host discordapp.com certificate verify failed #423

Closed
lcheng15 opened this issue Dec 24, 2016 · 11 comments
Closed

Cannot connect to host discordapp.com certificate verify failed #423

lcheng15 opened this issue Dec 24, 2016 · 11 comments

Comments

@lcheng15
Copy link

Hey guys

So I've just started trying to learn to build a Discord bot today but ran into this issue that's preventing me from running my bot.

I have installed Python 3.6 and the latest version of discord.py. I ran into this SSL certificate issue when I tried to run my bot, which is only a couple of lines.

import stuff...

token = 'my bot token here'
client = discord.Client()
client.run(token)

Instead of logging my bot in, I get the following error messages:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direct_connection
local_addr=self._local_addr)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 802, in create_connection
sock, protocol_factory, ssl, server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 828, in _create_connection_transport
yield from waiter
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py", line 503, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py", line 201, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect
yield from self._create_connection(req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_connection
transport, proto = yield from self._create_direct_connection(req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 624, in _create_direct_connection
(req.host, req.port, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 1] Can not connect to discordapp.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/lcheng15/Dropbox/DiscordBot/DiscordBot.py", line 14, in
client.run(token)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 490, in start
yield from self.login(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 416, in login
yield from getattr(self, 'login' + str(n))(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 346, in _login_1
data = yield from self.http.static_login(token, bot=is_bot)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 195, in static_login
data = yield from self.get(self.ME)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 105, in request
r = yield from self.session.request(method, url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 555, in iter
resp = yield from self._coro
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request
conn = yield from self._connector.connect(req)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect
.format(key, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 1] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)]]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x105cb2e80>

I have found others with the same error on the MusicBot's GitHub. They solved it by installing a certificate, which did not solve my problem. BTW, I'm running MacOS Sierra

I would really appreciate it if you guys could give me some help here. It's really frustrating when the first basic step fails. Thanks in advance!

@ButterCheezii
Copy link

Yeah, I believe the macOS version of python 3.6 is fucked. You might have to stick with a linux or windows machine because all that I've seen doesn't work on my machine (that has the same issue). I have a VPS so it's not much of a problem anyway, but just a heads up.

@omenos
Copy link

omenos commented Jan 10, 2017

Can confirm @ButterCheezii 's statement on my end. Using Python 3.6.0 in PyCharm (and terminal) on 10.10.5 resulted in the same error. Converting the project over to Python 3.5.2 fixed the issue. Didn't have to install a certificate or anything. Still trying to decide whether to use Heroku or pay $3 bucks a month for a VPS from OVH.

@Rapptz It may be worth mentioning this in the README

@Rapptz
Copy link
Owner

Rapptz commented Jan 12, 2017

I looked into this some more. Apparently 3.6 changed the installation process on OS X.

When you install there's this piece of information:

macOS users: If you are using the Python 3.6 from the python.org binary installer linked on this page, please carefully read the Important Information displayed during installation; this information is also available after installation by clicking on /Applications/Python 3.6/ReadMe.rtf. There is important information there about changes in the 3.6.0 installer-supplied Python, particularly with regard to SSL certificate validation.

When you head over to the ReadMe.rtf file you get more information as well:

Certificate verification and OpenSSL
--
NEW This variant of Python 3.6 now includes its own private copy of OpenSSL 1.0.2. Unlike previous releases, the deprecated Apple-supplied OpenSSL libraries are no longer used. This also means that the trust certificates in system and user keychains managed by the Keychain Access application and the security command line utility are no longer used as defaults by the Python ssl module. For 3.6.0, a sample command script is included in /Applications/Python 3.6 to install a curated bundle of default root certificates from the third-party certifi package (https://pypi.python.org/pypi/certifi). If you choose to use certifi, you should consider subscribing to the project's email update service to be notified when the certificate bundle is updated.
--
The bundled pip included with the Python 3.6 installer has its own default certificate store for verifying download connections.

Basically navigate to your Applications/Python 3.6/ folder and double click the Install Certificates.command.

Kind of a headache on the python dev group but also a pain from Apple's POV for providing deprecated binaries.

@Juice805
Copy link

Juice805 commented Apr 27, 2017

@Cmoen11 A fix was posted here, worked for me

@Deepanshu-Rohilla
Copy link

@Rapptz Thank You very much.

@VictorEstradaF
Copy link

VictorEstradaF commented Jun 4, 2020

How i install certificate command file in windows 10?

@retr0foxx
Copy link

I have this error on my windows 7 how do I repair it? I can't seem to find Install Certificates.command anywhere.

@AbstractUmbra
Copy link
Contributor

Please don't necro old Github issues.

This is more a question for the official help server.

To answer your question however: the certificate can be located here. Please download and install the certficate and restart your bot.

also, a location of the download link.

@Kylepollock
Copy link

I looked into this some more. Apparently 3.6 changed the installation process on OS X.

When you install there's this piece of information:

macOS users: If you are using the Python 3.6 from the python.org binary installer linked on this page, please carefully read the Important Information displayed during installation; this information is also available after installation by clicking on /Applications/Python 3.6/ReadMe.rtf. There is important information there about changes in the 3.6.0 installer-supplied Python, particularly with regard to SSL certificate validation.

When you head over to the ReadMe.rtf file you get more information as well:

Certificate verification and OpenSSL

NEW This variant of Python 3.6 now includes its own private copy of OpenSSL 1.0.2. Unlike previous releases, the deprecated Apple-supplied OpenSSL libraries are no longer used. This also means that the trust certificates in system and user keychains managed by the Keychain Access application and the security command line utility are no longer used as defaults by the Python ssl module. For 3.6.0, a sample command script is included in /Applications/Python 3.6 to install a curated bundle of default root certificates from the third-party certifi package (https://pypi.python.org/pypi/certifi). If you choose to use certifi, you should consider subscribing to the project's email update service to be notified when the certificate bundle is updated.

The bundled pip included with the Python 3.6 installer has its own default certificate store for verifying download connections.

Basically navigate to your Applications/Python 3.6/ folder and double click the Install Certificates.command.

Kind of a headache on the python dev group but also a pain from Apple's POV for providing deprecated binaries.

Thank you! This is still relevant!!!

@Harmon758
Copy link
Contributor

Please don't necro-bump old issues, even if it is just to express gratitude.

For the more recent issue (with a root certificate expiration) on Windows, see #4159.

@ARtheboss
Copy link

ARtheboss commented Feb 2, 2021

https://pypi.python.org/pypi/certifi

I looked into this some more. Apparently 3.6 changed the installation process on OS X.

When you install there's this piece of information:

macOS users: If you are using the Python 3.6 from the python.org binary installer linked on this page, please carefully read the Important Information displayed during installation; this information is also available after installation by clicking on /Applications/Python 3.6/ReadMe.rtf. There is important information there about changes in the 3.6.0 installer-supplied Python, particularly with regard to SSL certificate validation.

When you head over to the ReadMe.rtf file you get more information as well:

Certificate verification and OpenSSL

NEW This variant of Python 3.6 now includes its own private copy of OpenSSL 1.0.2. Unlike previous releases, the deprecated Apple-supplied OpenSSL libraries are no longer used. This also means that the trust certificates in system and user keychains managed by the Keychain Access application and the security command line utility are no longer used as defaults by the Python ssl module. For 3.6.0, a sample command script is included in /Applications/Python 3.6 to install a curated bundle of default root certificates from the third-party certifi package (https://pypi.python.org/pypi/certifi). If you choose to use certifi, you should consider subscribing to the project's email update service to be notified when the certificate bundle is updated.

The bundled pip included with the Python 3.6 installer has its own default certificate store for verifying download connections.

Basically navigate to your Applications/Python 3.6/ folder and double click the Install Certificates.command.

Kind of a headache on the python dev group but also a pain from Apple's POV for providing deprecated binaries.

Still not working for me. I'm getting the same error. Any other suggestions? (Python 3.7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests