-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ARM] Fix #20842: az bicep: Fix to use requests environment variables for CA bundle
#21807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,8 +109,8 @@ def ensure_bicep_installation(release_tag=None, target_platform=None, stdout=Tru | |
| print(f"Installing Bicep CLI {release_tag}...") | ||
| else: | ||
| print("Installing Bicep CLI...") | ||
| ca_file = certifi.where() | ||
| request = urlopen(_get_bicep_download_url(system, release_tag, target_platform=target_platform), cafile=ca_file) | ||
| os.environ.setdefault("CURL_CA_BUNDLE", certifi.where()) | ||
| request = urlopen(_get_bicep_download_url(system, release_tag, target_platform=target_platform)) | ||
| with open(installation_path, "wb") as f: | ||
| f.write(request.read()) | ||
|
|
||
|
|
@@ -143,17 +143,17 @@ def is_bicep_file(file_path): | |
|
|
||
| def get_bicep_available_release_tags(): | ||
| try: | ||
| ca_file = certifi.where() | ||
| response = requests.get("https://aka.ms/BicepReleases", verify=ca_file) | ||
| os.environ.setdefault("CURL_CA_BUNDLE", certifi.where()) | ||
| response = requests.get("https://aka.ms/BicepReleases") | ||
|
Comment on lines
+146
to
+147
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification, there is no need to set
If |
||
| return [release["tag_name"] for release in response.json()] | ||
| except IOError as err: | ||
| raise ClientRequestError(f"Error while attempting to retrieve available Bicep versions: {err}.") | ||
|
|
||
|
|
||
| def get_bicep_latest_release_tag(): | ||
| try: | ||
| ca_file = certifi.where() | ||
| response = requests.get("https://aka.ms/BicepLatestRelease", verify=ca_file) | ||
| os.environ.setdefault("CURL_CA_BUNDLE", certifi.where()) | ||
| response = requests.get("https://aka.ms/BicepLatestRelease") | ||
| response.raise_for_status() | ||
| return response.json()["tag_name"] | ||
| except IOError as err: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying @emitor's comment from e0bb745#r71858253:
Hi @wwmoraes,
urlopendoes not use the OS environmentCURL_CA_BUNDLEasrequestdoes. So if you remove thecafile=ca_fileparameter this break the commandaz bicepif you are behind a proxy using a custom CA.I'm trying to using this at work behind a corporate proxt and does not work anymore and throws the
[SSL: CERTIFICATE_VERIFY_FAILED]. I've manually modified the file locally and is working.In order to do it properly so
urlopendoes not throw any warnings, you should change it to something like this:Would you be able to fix this back please?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short,
urlopendoesn't supportREQUESTS_CA_BUNDLEorCURL_CA_BUNDLEand we shouldn't makeurlopensupport them either.