(self, proxy_url)
| 388 | conn.ca_certs = None |
| 389 | |
| 390 | def _setup_proxy_ssl_context(self, proxy_url): |
| 391 | proxies_settings = self._proxy_config.settings |
| 392 | proxy_ca_bundle = proxies_settings.get('proxy_ca_bundle') |
| 393 | proxy_cert = proxies_settings.get('proxy_client_cert') |
| 394 | if proxy_ca_bundle is None and proxy_cert is None: |
| 395 | return None |
| 396 | |
| 397 | context = self._get_ssl_context() |
| 398 | try: |
| 399 | url = parse_url(proxy_url) |
| 400 | # urllib3 disables this by default but we need it for proper |
| 401 | # proxy tls negotiation when proxy_url is not an IP Address |
| 402 | if not _is_ipaddress(url.host): |
| 403 | context.check_hostname = True |
| 404 | if proxy_ca_bundle is not None: |
| 405 | context.load_verify_locations(cafile=proxy_ca_bundle) |
| 406 | |
| 407 | if isinstance(proxy_cert, tuple): |
| 408 | context.load_cert_chain(proxy_cert[0], keyfile=proxy_cert[1]) |
| 409 | elif isinstance(proxy_cert, str): |
| 410 | context.load_cert_chain(proxy_cert) |
| 411 | |
| 412 | return context |
| 413 | except (OSError, URLLib3SSLError, LocationParseError) as e: |
| 414 | raise InvalidProxiesConfigError(error=e) |
| 415 | |
| 416 | def _get_connection_manager(self, url, proxy_url=None): |
| 417 | if proxy_url: |
no test coverage detected