0

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?

4
  • You could pass a context = ssl.create_default_context() and set the context.check_hostname=False, context.verify_mode = ssl.CERT_NONE and pass it with your urlopen(req, context=context) Commented Nov 12, 2021 at 23:59
  • Try running from the shell: Commented Nov 13, 2021 at 0:13
  • @SudheeshSinganamalla that was the key. thank you answer the question and I will accept Commented Nov 13, 2021 at 0:29
  • Try this : dev2qa.com/… Commented Nov 13, 2021 at 11:14

1 Answer 1

1

Try running from the shell:

/Applications/Python\ 3.8/Install\ Certificates.command 

Replace 3.8 with whatever version you're using.

Sign up to request clarification or add additional context in comments.

4 Comments

I had a certificate issue a few days ago and this worked for me.
The name of the directory isn't Python. It's "Python 3.8".
not there, nothing that starts with python
Not sure what's going on then. Sorry. Maybe search your machine to see if this file is located somewhere else.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.