Skip to content

[Identity] connection_verify not working in Azure Identity #11944

@jiasli

Description

@jiasli
  • Package Name: Identity
  • Package Version: 1.4.0b4
  • Operating System: Windows
  • Python Version: 3.8.3

Describe the bug
When connection_verify=False is used to create any credential, like InteractiveBrowserCredential, RequestsTransport will be configured as self.connection_config.verify=False:

self.connection_config = ConnectionConfiguration(**kwargs)

self.verify = kwargs.pop('connection_verify', True)

However, when a real request is made:

def get(self, url, headers=None, params=None, timeout=None, verify=None, **kwargs):
# type: (str, Optional[Mapping[str, str]], Optional[Dict[str, str]], float, bool, Any) -> MsalTransportResponse
request = HttpRequest("GET", url, headers=headers)
if params:
request.format_parameters(params)
response = self._pipeline.run(
request, stream=False, connection_timeout=timeout, connection_verify=verify, **kwargs
)
return MsalTransportResponse(response)

verify will default to None, resulting in connection_verify=None being sent to self._pipeline.run. This causes self.connection_config.verify being overridden.

verify=kwargs.pop('connection_verify', self.connection_config.verify),

image

verify=None will be considered as verify=True by requests.

https://github.com/psf/requests/blob/9ed5db8ed28e816b597dafd328b342ec95466afa/requests/sessions.py#L389-L390

        #: SSL Verification default.
        self.verify = True

https://github.com/psf/requests/blob/9ed5db8ed28e816b597dafd328b342ec95466afa/requests/sessions.py#L710

        verify = merge_setting(verify, self.verify)

Possible solutions:

  • Azure Core needs to use the is not None approach for a more robust parameter resolution:
    verify = kwargs.pop('connection_verify', None)
    response = self.session.request(  # type: ignore
        ...
        verify=verify if verify is not None else self.connection_config.verify,        
    @lmazuel
  • Azure Identity stops passing connection_verify=None when verify is not given. @chlowell

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions