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?
context = ssl.create_default_context()and set thecontext.check_hostname=False,context.verify_mode = ssl.CERT_NONEand pass it with yoururlopen(req, context=context)