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

How to fix SSL: CERTIFICATE_VERIFY_FAILED? #84

Closed
nazandr opened this issue Nov 16, 2016 · 2 comments
Closed

How to fix SSL: CERTIFICATE_VERIFY_FAILED? #84

nazandr opened this issue Nov 16, 2016 · 2 comments

Comments

@nazandr
Copy link

nazandr commented Nov 16, 2016

{'feed': {}, 'entries': [], 'bozo': 1, 'bozo_exception': URLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),)}
It works some day ago, but now doesn't.

feedparser.parse('https://habrahabr.ru/rss/feed/posts/5d0c9b4397559e2e7cb380b29ec8151b/')

@davidag
Copy link

davidag commented Aug 24, 2019

This is due to Python starting to apply certificate verification by default for stdlib http clients.

A great explanation of the rationale of the change can be found in this Redhat article, along with information regarding how to control and troubleshoot this new situation.

Both previous references explain how to avoid certificate verification in single connections:

import ssl

# This restores the same behavior as before.
context = ssl._create_unverified_context()
urllib.urlopen("https://no-valid-cert", context=context)

Currently, feedparser users can only avoid certificate verification by monkeypatching (see previous links and this stackoverflow question), which is highly discouraged as it affects the whole application.

It seems that this issue could be fixed if feedparser.parse() had support for enabling/disabling this certificate validation in any way.

As a sidenote, Firefox is not so restrictive with feeds from sites with invalid certificates and you can access them without a warning, even if visiting the main site will rise a big warning screen.

@kurtmckee
Copy link
Owner

feedparser will eventually lose its internal HTTP code, likely in favor of using requests.

I recommend that developers begin using standard HTTP clients like the requests module to address intricacies like SSL verification.

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

3 participants