code: def _get_tls_context(self) -> ssl.SSLContext:
          
          if self.tls_context is not None:
              context = self.tls_context
          else:
              # SERVER_AUTH is what we want for a client side socket
              context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
              context.check_hostname = bool(self.validate_certs)
              if self.validate_certs:
                  context.verify_mode = ssl.CERT_REQUIRED
              else:
                  context.verify_mode = ssl.CERT_NONE
  
              if self.cert_bundle is not None:
                  context.load_verify_locations(cafile=self.cert_bundle)
  
              if self.client_cert is not None:
                  context.load_cert_chain(self.client_cert, keyfile=self.client_key)
  
          return context
docs: Build an SSLContext object from the options we've been given.