def setUp(self): self._temp_dir = tempfile.mkdtemp(prefix='sslproxy_', dir='/tmp') self.ca = self._temp_dir + 'testCA.pem' self.cert = self._temp_dir + 'testCA-cert.cer' self.wrong_ca = self._temp_dir + 'wrong.pem' self.wrong_cert = self._temp_dir + 'wrong-cert.cer' c, k = certutils.generate_dummy_ca() certutils.write_dummy_ca(self.ca, c, k) c, k = certutils.generate_dummy_ca() certutils.write_dummy_ca(self.wrong_ca, c, k)
def test_cert_store(self): ca_path = os.path.join(self._temp_dir, 'testCA.pem') cert, key = certutils.generate_dummy_ca() certutils.write_dummy_ca(ca_path, cert, key) cert_store = certutils.CertStore(ca_path) cert_dir = cert_store.cert_dir # Test cleanup self.assertTrue(os.path.exists(cert_dir)) cert_store.cleanup() self.assertFalse(os.path.exists(cert_dir))
def test_write_dummy_ca(self): base_path = os.path.join(self._temp_dir, 'testCA') ca_path = base_path + '.pem' ca_pem = base_path + '-cert.pem' ca_android = base_path + '-cert.cer' ca_windows = base_path + '-cert.p12' self.assertFalse(os.path.exists(ca_path)) self.assertFalse(os.path.exists(ca_pem)) self.assertFalse(os.path.exists(ca_android)) self.assertFalse(os.path.exists(ca_windows)) c, k = certutils.generate_dummy_ca() certutils.write_dummy_ca(ca_path, c, k) self._check_cert_file(ca_path, c, k) self._check_cert_file(ca_pem, c) self._check_cert_file(ca_android, c) self.assertTrue(os.path.exists(ca_windows))
def test_generate_dummy_ca(self): subject = 'testSubject' c, _ = certutils.generate_dummy_ca(subject) self.assertEqual(c.get_subject().commonName, subject)