'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.'

def VerifyServerPEM(self, http_object):

    try:
        server_pem = http_object.data
        server_url = http_object.url
        if ('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
