`
cooler1217
  • 浏览: 378388 次
  • 性别: Icon_minigender_1
  • 来自: 长春
社区版块
存档分类
最新评论

Python访问https报错CERTIFICATE_VERIFY_FAILED

 
阅读更多
在Mac上安装了Python 3.6版本,使用urllib库访问网页却返回了

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
1
这样的错误。

这是由于MacOS版本的python 3.6版本没有使用系统的openssl进行证书验证。在/Applications/Python\ 3.6/目录下可以找到Readme.rtf文件,其中说明到:

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.

解决方法是运行/Applications/Python\ 3.6/Install\ Certificates.command命令,安装certifi模块即可。

可见stackoverflow上的帖子:
urllib and “SSL: CERTIFICATE_VERIFY_FAILED” Error
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics