code: def authenticate_with_certificate_chain(reactor, base_url, client_chain, client_key, ca_cert):
      
      if base_url.scheme != u"https":
          raise ValueError(
              "authenticate_with_certificate() makes sense for HTTPS, not {!r}".format(
                  base_url.scheme
              ),
          )
  
      netloc = NetLocation(host=base_url.host, port=base_url.port)
      policy = ClientCertificatePolicyForHTTPS(
          credentials={
              netloc: TLSCredentials(
                  chain=Chain(certificates=Certificates(client_chain)),
                  key=client_key,
              ),
          },
          trust_roots={
              netloc: ca_cert,
          },
      )
      return Agent(reactor, contextFactory=policy)
docs: Create an ``IAgent`` which can issue authenticated requests to a
      particular Kubernetes server using a client certificate.
  
      :param reactor: The reactor with which to configure the resulting agent.
  
      :param twisted.python.url.URL base_url: The base location of the
          Kubernetes API.
  
      :param list[pem.Certificate] client_chain: The client certificate (and
          chain, if applicable) to use.
  
      :param pem.Key client_key: The private key to use with the client
          certificate.
  
      :param pem.Certificate ca_cert: The certificate authority to respect when
          verifying the Kubernetes server certificate.
  
      :return IAgent: An agent which will authenticate itself to a particular
          Kubernetes server and which will verify that server or refuse to
          interact with it.