# Buggy code
def __init__(
    self,
    *,
    auth: AuthTypes = None,
    params: QueryParamTypes = None,
    headers: HeaderTypes = None,
    cookies: CookieTypes = None,
    verify: VerifyTypes = True,
    cert: CertTypes = None,
    http_versions: HTTPVersionTypes = None,
    proxies: ProxiesTypes = None,
    timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
    pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,
    max_redirects: int = DEFAULT_MAX_REDIRECTS,
    base_url: URLTypes = None,
    dispatch: typing.Union[AsyncDispatcher, Dispatcher] = None,
    app: typing.Callable = None,
    backend: ConcurrencyBackend = None,
    trust_env: bool = True,
):
    if backend is None:
        backend = AsyncioBackend()

    self.check_concurrency_backend(backend)

    if app is not None:
        param_count = len(inspect.signature(app).parameters)
        assert param_count in (2, 3)
        if param_count == 2:
            dispatch = WSGIDispatch(app=app)
        else:
            dispatch = ASGIDispatch(app=app, backend=backend)

    self.trust_env = True if trust_env is None else trust_env

    if dispatch is None:
        async_dispatch: AsyncDispatcher = ConnectionPool(
            verify=verify,
            cert=cert,
            timeout=timeout,
            http_versions=http_versions,
            pool_limits=pool_limits,
            backend=backend,
            trust_env=self.trust_env,
        )
    elif isinstance(dispatch, Dispatcher):
        async_dispatch = ThreadedDispatcher(dispatch, backend)
    else:
        async_dispatch = dispatch

    if base_url is None:
        self.base_url = URL("", allow_relative=True)
    else:
        self.base_url = URL(base_url)

    if proxies is None and trust_env:
        proxies = typing.cast(ProxiesTypes, get_environment_proxies())

    self.proxies: typing.Dict[str, AsyncDispatcher] = _proxies_to_dispatchers(proxies)

    if params is None:
        params = {}

    self.auth = auth
    self._params = QueryParams(params)
    self._headers = Headers(headers)
    self._cookies = Cookies(cookies)
    self.max_redirects = max_redirects
    self.dispatch = async_dispatch
    self.concurrency_backend = backend


# Traceback (ssl.SSLCertVerificationError)
SSL handshake failed on verifying the certificate
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000020CDCD7E470>
transport: <_SelectorSocketTransport fd=768 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 625, in _on_handshake_complete
raise handshake_exc
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 763, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
SSL error in data received
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000020CDCD7E470>
transport: <_SelectorSocketTransport closing fd=768 read=idle write=<idle, bufsize=0>>
Traceback (most recent call last):
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 526, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 763, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
Traceback (most recent call last):
File "C:/Users/localhost/PycharmProjects/TribalW_Test_Env/Basic/tests/httpx/proxy_test.py", line 11, in <module>
request = client.get("http://whoer.net",headers=headers,verify=client_cer)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 818, in get
proxies=proxies,
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 729, in request
proxies=proxies,
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 760, in send
async_response = concurrency_backend.run(coroutine, *args, **kwargs)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\concurrency\asyncio.py", line 241, in run
return self.loop.run_until_complete(coroutine(*args, **kwargs))
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 584, in run_until_complete
return future.result()
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 230, in _get_response
return await get_response(request)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\middleware\redirect.py", line 41, in __call__
return await self(next_request, get_response)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\middleware\redirect.py", line 31, in __call__
response = await get_response(request)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 191, in get_response
request, verify=verify, cert=cert, timeout=timeout
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 243, in send
request=request, verify=verify, cert=cert, timeout=timeout
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\connection_pool.py", line 118, in send
connection = await self.acquire_connection(origin=request.url.origin)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 92, in acquire_connection
return await self.tunnel_connection(origin)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 110, in tunnel_connection
await self.tunnel_start_tls(origin, connection)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 194, in tunnel_start_tls
timeout=timeout,
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\concurrency\asyncio.py", line 216, in start_tls
timeout=timeout.connect_timeout,
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\tasks.py", line 416, in wait_for
return fut.result()
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 1134, in start_tls
await waiter
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 526, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 763, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)

# Fixed code
def __init__(
    self,
    *,
    auth: AuthTypes = None,
    params: QueryParamTypes = None,
    headers: HeaderTypes = None,
    cookies: CookieTypes = None,
    verify: VerifyTypes = True,
    cert: CertTypes = None,
    http_versions: HTTPVersionTypes = None,
    proxies: ProxiesTypes = None,
    timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
    pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,
    max_redirects: int = DEFAULT_MAX_REDIRECTS,
    base_url: URLTypes = None,
    dispatch: typing.Union[AsyncDispatcher, Dispatcher] = None,
    app: typing.Callable = None,
    backend: ConcurrencyBackend = None,
    trust_env: bool = True,
):
    if backend is None:
        backend = AsyncioBackend()

    self.check_concurrency_backend(backend)

    if app is not None:
        param_count = len(inspect.signature(app).parameters)
        assert param_count in (2, 3)
        if param_count == 2:
            dispatch = WSGIDispatch(app=app)
        else:
            dispatch = ASGIDispatch(app=app, backend=backend)

    self.trust_env = True if trust_env is None else trust_env

    if dispatch is None:
        async_dispatch: AsyncDispatcher = ConnectionPool(
            verify=verify,
            cert=cert,
            timeout=timeout,
            http_versions=http_versions,
            pool_limits=pool_limits,
            backend=backend,
            trust_env=self.trust_env,
        )
    elif isinstance(dispatch, Dispatcher):
        async_dispatch = ThreadedDispatcher(dispatch, backend)
    else:
        async_dispatch = dispatch

    if base_url is None:
        self.base_url = URL("", allow_relative=True)
    else:
        self.base_url = URL(base_url)

    if params is None:
        params = {}

    self.auth = auth
    self._params = QueryParams(params)
    self._headers = Headers(headers)
    self._cookies = Cookies(cookies)
    self.max_redirects = max_redirects
    self.dispatch = async_dispatch
    self.concurrency_backend = backend

    if proxies is None and trust_env:
        proxies = typing.cast(ProxiesTypes, get_environment_proxies())

    self.proxies: typing.Dict[str, AsyncDispatcher] = _proxies_to_dispatchers(
        proxies,
        verify=verify,
        cert=cert,
        timeout=timeout,
        http_versions=http_versions,
        pool_limits=pool_limits,
        backend=backend,
        trust_env=trust_env,
    )