Skip to content

Instantly share code, notes, and snippets.

@patharanordev
Last active February 14, 2021 02:54
Show Gist options
  • Save patharanordev/51d0be90fb2a37360f1a00dbed618179 to your computer and use it in GitHub Desktop.
Save patharanordev/51d0be90fb2a37360f1a00dbed618179 to your computer and use it in GitHub Desktop.
Correct way to solve "CERTIFICATE_VERIFY_FAILED" issue

Solved SSL:CERTIFICATE_VERIFY_FAILED in Python

... [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
import ssl

ssl._create_default_https_context = ssl._create_unverified_context

Above isn't a solution to your specific problem, but I'm putting it here because this thread is the top Google result for "SSL: CERTIFICATE_VERIFY_FAILED", and it lead me on a wild goose chase.

If you have installed Python 3.6 on OSX and are getting the "SSL: CERTIFICATE_VERIFY_FAILED" error when trying to connect to an https:// site, it's probably because Python 3.6 on OSX has no certificates at all, and can't validate any SSL connections. This is a change for 3.6 on OSX, and requires a post-install step, which installs the certifi package of certificates. This is documented in the ReadMe, which you should find at /Applications/Python\ 3.6/ReadMe.rtf

The ReadMe will have you run this post-install script, which just installs certifi:

$ /Applications/Python\ 3.6/Install\ Certificates.command

For MacOS :

$ cd "/Applications/Python 3.6/"
$ "./Install Certificates.command"

Release notes have some more info: https://www.python.org/downloads/release/python-360/

Ref. https://stackoverflow.com/a/42334357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment