I am running python3 on Mac Mojavee I have the following code
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
req = Request("https://cognito-idp.us-west-2.amazonaws.com/us-west-2_OnQppLqYQ/.well-known/jwks.json")
try:
response = urlopen(req)
except HTTPError as e:
print('Error code: ', e.code)
except URLError as e:
print('Reason: ', e.reason)
else:
print('good!')
when I run it with python3, I get the famous cert error:
Reason: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)
I have read so many posts on this here and I am still stuck.
Anyone can help guide me?
CodePudding user response:
Try running from the shell:
/Applications/Python\ 3.8/Install\ Certificates.command
Replace 3.8 with whatever version you're using.
CodePudding user response:
If this also has an HTTP version and you do not care about security, you could just change "https://" to "http://" in the URL.
However, if one or more of those conditions are not true, then it sounds like you need to provide a certificate to satsify SSL. This previous SO post may be helpful in acquiring them:
Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org