talkpython / async-techniques-python-course

Async Techniques and Examples in Python Course
https://training.talkpython.fm/courses/explore_async_python/async-in-python-with-threading-and-multiprocessing
MIT License
451 stars 249 forks source link

SSL: Certificate Failure Episode Async web scraping #7

Closed androiddrew closed 5 years ago

androiddrew commented 5 years ago

For the web scraping component against https://talkpython.fm I was successful using the sync libraries and code with a 3.6 interpreter, however when moving on to the async version I get:

aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host talkpython.fm:443 ssl:None [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)]
mikeckennedy commented 5 years ago

I started running into this issue after awhile too. Was very weird. Must be some update to aiohttp? Anyway, you can avoid the error if you set a value in the ClientSession, see this example:

https://github.com/talkpython/async-techniques-python-course/blob/23d7f68b5289e3478b70b30fd206f3dab42996e7/src/09-built-on-asyncio/the_unsync/presync.py

androiddrew commented 5 years ago

So the 3.6.5 interpreter I am using was installed from python.org. When I homebrew installed python I got a 3.7 interpreter and I did notice that openssl was present under the Cellar.

Checking the 3.7 interpreter I got:

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2p  14 Aug 2018'

The 3.6.5 interpreter had:

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2n  7 Dec 2017'

So the issue could be this maybe. I am switching to the homebrew version for the rest of the class I guess.

mikeckennedy commented 5 years ago

Oh weird! Yes, this is possible. FWIW, I'm using homebrew in the course.

Best, Michael

On Fri, Oct 19, 2018 at 10:12 AM Drew notifications@github.com wrote:

So the 3.6.5 interpreter I am using was installed from python.org. When I homebrew installed python I got a 3.7 interpreter and I did notice that openssl was present under the Cellar.

Checking the 3.7 interpreter I got:

import ssl ssl.OPENSSL_VERSION 'OpenSSL 1.0.2p 14 Aug 2018'

The 3.6.5 interpreter had:

import ssl ssl.OPENSSL_VERSION 'OpenSSL 1.0.2n 7 Dec 2017'

So the issue could be this maybe. I am switching to the homebrew version for the rest of the class I guess.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/talkpython/async-techniques-python-course/issues/7#issuecomment-431433501, or mute the thread https://github.com/notifications/unsubscribe-auth/AB8PadwlCHqmfmc01N5lQUIRwkU1LSP-ks5umggIgaJpZM4XxB18 .