{"id":3714,"date":"2020-05-20T10:52:37","date_gmt":"2020-05-20T02:52:37","guid":{"rendered":"https:\/\/www.ookangzheng.com\/?p=3714"},"modified":"2020-05-24T15:57:57","modified_gmt":"2020-05-24T07:57:57","slug":"python3-on-mac-ssl-certificate-verify-failed","status":"publish","type":"post","link":"https:\/\/www.ookangzheng.com\/python3-on-mac-ssl-certificate-verify-failed\/","title":{"rendered":"Python3 on Mac SSL certificate verify failed"},"content":{"rendered":"\n
Lib: json, urllib.request<\/p>\n\n\n\n
Sample code<\/p>\n\n\n\n
import json\nfrom urllib.request import urlopen\n\nurl = \"https:\/\/api.github.com\/\"\n\ndef get(url, object_hook=None):\n with urlopen(url) as resource:\n return json.load(resource, object_hook=object_hook)\n\ndata = get(url)\nprint(data)<\/code><\/pre>\n\n\n\nError<\/p>\n\n\n\n
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)><\/code><\/pre>\n\n\n\nSolution via Install Certificate.command<\/em><\/p>\n\n\n\n