Repository navigation
MSAL authentication doesn't respect REQUESTS_CA_BUNDLE for proxy certificates #32207
Description
Describe the bug
MSAL authentication in Azure CLI doesn't respect the REQUESTS_CA_BUNDLE environment variable when
working behind a proxy with custom certificates. While other Azure CLI operations properly use custom CA
bundles specified via REQUESTS_CA_BUNDLE, the MSAL library used for authentication (particularly az login) ignores this setting, causing SSL certificate verification errors even when users have correctly
configured their proxy certificates according to the official documentation.
Related command
az login
az login --debug
Errors
Certificate verification failed. This typically happens when using Azure CLI behind a proxy that intercepts traffic with a self-signed certificate.
SSL: CERTIFICATE_VERIFY_FAILED
Issue script & Debug output
Environment setup
export HTTPS_PROXY=https://corporate-proxy:8080
export REQUESTS_CA_BUNDLE=/path/to/custom-ca-bundle.pem
Run login with debug
az login --debug
Debug output shows NO indication of using custom cert bundle for MSAL:
DEBUG: Getting management service client client_type=SubscriptionClient
DEBUG: urllib3.connectionpool: Starting new HTTPS connection
ERROR: SSL: CERTIFICATE_VERIFY_FAILED
Expected debug output (missing):
DEBUG: MSAL: Using CA bundle file at '/path/to/custom-ca-bundle.pem'
Other az commands work fine with the same REQUESTS_CA_BUNDLE:
az vm list --debug
Shows: DEBUG: Using CA bundle file at '/path/to/custom-ca-bundle.pem'
Expected behavior
When REQUESTS_CA_BUNDLE environment variable is set:
- MSAL authentication should use the specified custom CA bundle file
az login --debugshould show debug message indicating the custom CA bundle is being used- Authentication should succeed without SSL certificate verification errors
- Behavior should be consistent with other Azure CLI operations that already respect this environment
variable
This is documented behavior according to:
https://learn.microsoft.com/en-us/cli/azure/use-azure-cli-successfully-troubleshooting#work-behind-a-pro
xy
Environment Summary
azure-cli 2.77.0
core 2.77.0
telemetry 1.1.0
Dependencies:
msal 1.34.0b1
azure-mgmt-resource 23.3.0
Python location '/opt/homebrew/Cellar/azure-cli/2.77.0/libexec/bin/python'
Config directory '/Users/ciaranfinnegan/.azure'
Extensions directory '/Users/ciaranfinnegan/.azure/cliextensions'
Python (Darwin) 3.13.7 (main, Aug 14 2025, 11:12:11) [Clang 17.0.0 (clang-1700.0.13.3)]
Additional context
No response
Activity
yonzhan commentedon Oct 1, 2025
Thank you for opening this issue, we will look into it.
github-actions commentedon Oct 1, 2025
Here are some similar issues that might help you. Please check if they can solve your problem.
Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)
Solution 1:
Downgrade Azure CLI to version 2.76.0, which does not exhibit this issue. Use the following script to downgrade:
Reference:
Solution 2:
Ensure that the certificate being used includes the
Authority Key Identifier(AKI) property. This is required due to stricter SSL controls introduced in Python 3.13, which Azure CLI 2.77.0 uses. Certificates without the AKI property will fail verification.Reference:
Solution 3:
Set the environment variable
AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1as a workaround to bypass SSL verification. Note that this is not recommended for production environments due to security risks.Reference:
Powered by issue-sentinel
brow86 commentedon Oct 3, 2025
We have encountered this as a byproduct of ZScaler. For
az loginthe workaround was to set PYTHONVERIFY=0. There are otherazcommands that won't respect this, likeaz aks install. That would indicate the modules aren't using a consistent path for connecting.jiasli commentedon Oct 14, 2025
It is by design that
AZURE_CLI_DISABLE_CONNECTION_VERIFICATIONis not honored when calling MSAL during authentication, as disabling SSL verification puts Azure CLI at risk. Setting the root CA withREQUESTS_CA_BUNDLEis the only supported approach.We haven't observed that MSAL doesn't respect
REQUESTS_CA_BUNDLE. In my recent experiment #32083 (comment), MSAL does honorREQUESTS_CA_BUNDLEwhen connecting tologin.microsoftonline.com.feat: add `proxy` and `SSL certificate` support for `AWS, Azure, and …