Skip to content

Conversation

@sajid-01
Copy link

In the current page, the code only declares the context variable using
context = ssl._create_unverified_context()
but it doesn’t include passing this variable as the second argument to urllib.request.urlopen().
Without adding the context to the function call, the error
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1077)>
still appears on some macOS setups.

This change adds the missing part by including the context parameter in the request call:
request = urllib.request.urlopen(address, context = my_context)
and also defines the address variable for clarity.
This ensures the function actually works as intended and resolves the SSL certificate error on macOS.

…cate error

In the current page, the code only declares the context variable using

context = ssl._create_unverified_context()

but it never shows that this variable needs to be passed as the second argument to urllib.request.urlopen().

Without adding the context to the function call, the error

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1077)>

still appears on some macOS setups.

This change adds the missing part by including the context parameter in the request call:

request = urllib.request.urlopen(address, context=my_context)

and also defines the address variable for clarity.

This ensures the function actually works as intended and resolves the SSL certificate error on macOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant