def get_server_cert(self, host):
     """Gets certificate from the server and stores it in archive"""
     request = ArchivedHttpRequest('SERVER_CERT', host, '', None, {})
     if request not in self:
         self[request] = create_response(200,
                                         body=certutils.get_host_cert(host))
     return self[request].response_data[0]
Esempio n. 2
0
 def get_server_cert(self, host):
   """Gets certificate from the server and stores it in archive"""
   request = ArchivedHttpRequest('SERVER_CERT', host, '', None, {})
   if request not in self:
     self[request] = create_response(200, body=certutils.get_host_cert(host,
                                                                       real_dns_lookup=self._real_dns_lookup))
   return self[request].response_data[0]
Esempio n. 3
0
    def test_get_host_cert(self):
        ca_cert_path = os.path.join(self._temp_dir, 'rootCA.pem')
        issuer = 'testCA'
        certutils.write_dummy_ca_cert(
            *certutils.generate_dummy_ca_cert(issuer), cert_path=ca_cert_path)

        with Server(ca_cert_path) as server:
            cert_str = certutils.get_host_cert('localhost', server.server_port)
            cert = certutils.load_cert(cert_str)
            self.assertEqual(issuer, cert.get_subject().commonName)
Esempio n. 4
0
  def test_get_host_cert(self):
    ca_cert_path = os.path.join(self._temp_dir, 'rootCA.pem')
    issuer = 'testCA'
    certutils.write_dummy_ca_cert(*certutils.generate_dummy_ca_cert(issuer),
                                  cert_path=ca_cert_path)

    with Server(ca_cert_path) as server:
      cert_str = certutils.get_host_cert('localhost', server.server_port)
      cert = certutils.load_cert(cert_str)
      self.assertEqual(issuer, cert.get_subject().commonName)
Esempio n. 5
0
 def test_get_host_cert_gives_empty_for_bad_host(self):
     cert_str = certutils.get_host_cert(
         'not_a_valid_host_name_2472341234234234')
     self.assertEqual('', cert_str)
Esempio n. 6
0
 def test_get_host_cert_gives_empty_for_bad_host(self):
   cert_str = certutils.get_host_cert('not_a_valid_host_name_2472341234234234')
   self.assertEqual('', cert_str)