Skip to content

Commit

Permalink
{Core} Capture SSLError raised by Track 2 SDKs (#23074)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasli authored Jun 30, 2022
1 parent 75a6af8 commit 44b8c11
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def handle_exception(ex): # pylint: disable=too-many-locals, too-many-statement
from msrestazure.azure_exceptions import CloudError
from msrest.exceptions import HttpOperationError, ValidationError, ClientRequestError
from azure.common import AzureException
from azure.core.exceptions import AzureError
from azure.core.exceptions import AzureError, ServiceRequestError
from requests.exceptions import SSLError, HTTPError
from azure.cli.core import azclierror
from msal_extensions.persistence import PersistenceError
Expand All @@ -79,7 +79,11 @@ def handle_exception(ex): # pylint: disable=too-many-locals, too-many-statement
az_error = azclierror.InvalidArgumentValueError(error_msg)
az_error.set_recommendation(QUERY_REFERENCE)

elif isinstance(ex, SSLError):
# SSLError is raised when making HTTP requests with 'requests' lib behind a proxy that intercepts HTTPS traffic.
# - SSLError is raised when directly calling 'requests' lib, such as MSAL or `az rest`
# - azure.core.exceptions.ServiceRequestError is raised when indirectly calling 'requests' lib with azure.core,
# which wraps the original SSLError
elif isinstance(ex, SSLError) or isinstance(ex, ServiceRequestError) and isinstance(ex.inner_exception, SSLError):
az_error = azclierror.AzureConnectionError(error_msg)
az_error.set_recommendation(SSLERROR_TEMPLATE)

Expand Down

0 comments on commit 44b8c11

Please sign in to comment.