Add missing SSL context argument in retrieve_all() to fix Mac certificate error#87
Open
Add missing SSL context argument in retrieve_all() to fix Mac certificate error#87
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.