def VerifyServerPEM(self, http_object):
    """Check the server PEM for validity.

    This is used to determine connectivity to the server. Sometimes captive
    portals return a valid HTTP status, but the data is corrupted.

    Args:
      http_object: The response received from the server.

    Returns:
      True if the response contains a valid server certificate.
    """
    try:
      server_pem = http_object.data
      server_url = http_object.url

      if b"BEGIN CERTIFICATE" in server_pem:
        # Now we know that this proxy is working. We still have to verify the
        # certificate. This will raise if the server cert is invalid.
        server_certificate = rdf_crypto.RDFX509Cert(server_pem)
        self.communicator.LoadServerCertificate(
            server_certificate=server_certificate, ca_certificate=self.ca_cert)

        logging.info("Server PEM re-keyed.")
        return True
    except Exception as e:  # pylint: disable=broad-except
      logging.info("Unable to verify server certificate at %s: %s", server_url,
                   e)

      return False
def VerifyServerPEM ( self , http_object ) : try : server_pem = http_object . data server_url = http_object . url if b"BEGIN CERTIFICATE" in server_pem : server_certificate = rdf_crypto . RDFX509Cert ( server_pem ) self . communicator . LoadServerCertificate ( server_certificate = server_certificate , ca_certificate = self . ca_cert ) logging . info ( "Server PEM re-keyed." ) return True except Exception as e : logging . info ( "Unable to verify server certificate at %s: %s" , server_url , e ) return False
Check the server PEM for validity.

    This is used to determine connectivity to the server. Sometimes captive
    portals return a valid HTTP status, but the data is corrupted.

    Args:
      http_object: The response received from the server.

    Returns:
      True if the response contains a valid server certificate.