def _get_pool_manager(verify, cert_file, key_file): global _pool_manager default_pool_args = dict(maxsize=32, cert_reqs=ssl.CERT_REQUIRED, ca_certs=_default_certs, headers=_default_headers, timeout=_default_timeout) if cert_file is None and verify is None and 'DX_CA_CERT' not in os.environ: with _pool_mutex: if _pool_manager is None: if 'HTTPS_PROXY' in os.environ: proxy_params = _get_proxy_info(os.environ['HTTPS_PROXY']) default_pool_args.update(proxy_params) _pool_manager = urllib3.ProxyManager(**default_pool_args) else: _pool_manager = urllib3.PoolManager(**default_pool_args) return _pool_manager else: # This is the uncommon case, normally, we want to cache the pool # manager. pool_args = dict(default_pool_args, cert_file=cert_file, key_file=key_file, ca_certs=verify or os.environ.get('DX_CA_CERT') or requests.certs.where()) if verify is False or os.environ.get('DX_CA_CERT') == 'NOVERIFY': pool_args.update(cert_reqs=ssl.CERT_NONE, ca_certs=None) urllib3.disable_warnings() if 'HTTPS_PROXY' in os.environ: proxy_params = _get_proxy_info(os.environ['HTTPS_PROXY']) pool_args.update(proxy_params) return urllib3.ProxyManager(**pool_args) else: return urllib3.PoolManager(**pool_args)
def _get_pool_manager(verify, cert_file, key_file): global _pool_manager default_pool_args = dict(maxsize=32, cert_reqs=ssl.CERT_REQUIRED, headers=_default_headers, timeout=_default_timeout) # Don't define a default CA bundle on Windows platforms - urllib3 and # ssl.py take care of loading the default CA list provided by the OS. # Plus, explicitly setting a CA list in the pool manager on Windows # can sometimes cause verification failures; see DEVEX-875. # But non-Windows platforms require setting a ca_certs bundle here: if platform.system() != 'Windows': default_pool_args.update(ca_certs=_default_certs) if cert_file is None and verify is None and 'DX_CA_CERT' not in os.environ: with _pool_mutex: if _pool_manager is None: if _get_env_var_proxy(): proxy_params = _get_proxy_info( _get_env_var_proxy(print_proxy=True)) default_pool_args.update(proxy_params) _pool_manager = urllib3.ProxyManager(**default_pool_args) else: _pool_manager = urllib3.PoolManager(**default_pool_args) return _pool_manager else: # This is the uncommon case, normally, we want to cache the pool # manager. pool_args = dict(default_pool_args, cert_file=cert_file, key_file=key_file, ca_certs=verify or os.environ.get('DX_CA_CERT') or requests.certs.where()) if verify is False or os.environ.get('DX_CA_CERT') == 'NOVERIFY': pool_args.update(cert_reqs=ssl.CERT_NONE, ca_certs=None) urllib3.disable_warnings() if _get_env_var_proxy(): proxy_params = _get_proxy_info( _get_env_var_proxy(print_proxy=True)) pool_args.update(proxy_params) return urllib3.ProxyManager(**pool_args) else: return urllib3.PoolManager(**pool_args)
def _get_pool_manager(verify, cert_file, key_file): global _pool_manager default_pool_args = dict(maxsize=32, cert_reqs=ssl.CERT_REQUIRED, headers=_default_headers, timeout=_default_timeout) # Don't use the default CA bundle if the user has set the env variable # DX_USE_OS_CA_BUNDLE. Enabling that var will make us attempt to load # the default CA certs provided by the OS; see DEVEX-875. if 'DX_USE_OS_CA_BUNDLE' not in os.environ: default_pool_args.update(ca_certs=_default_certs) if cert_file is None and verify is None and 'DX_CA_CERT' not in os.environ: with _pool_mutex: if _pool_manager is None: if _get_env_var_proxy(): proxy_params = _get_proxy_info( _get_env_var_proxy(print_proxy=True)) default_pool_args.update(proxy_params) _pool_manager = urllib3.ProxyManager(**default_pool_args) else: _pool_manager = urllib3.PoolManager(**default_pool_args) return _pool_manager else: # This is the uncommon case, normally, we want to cache the pool # manager. pool_args = dict(default_pool_args, cert_file=cert_file, key_file=key_file, ca_certs=verify or os.environ.get('DX_CA_CERT') or requests.certs.where()) if verify is False or os.environ.get('DX_CA_CERT') == 'NOVERIFY': pool_args.update(cert_reqs=ssl.CERT_NONE, ca_certs=None) urllib3.disable_warnings() if _get_env_var_proxy(): proxy_params = _get_proxy_info( _get_env_var_proxy(print_proxy=True)) pool_args.update(proxy_params) return urllib3.ProxyManager(**pool_args) else: return urllib3.PoolManager(**pool_args)