def test_gen_cacert_with_file_storage(self): cert_path = self.tmp_dir + 'cert.pem' key_path = self.tmp_dir + 'key.pem' chain_path = self.tmp_dir + 'cert.chain' pkcs7_path = self.tmp_dir + 'cert.p7b' subject_dn = 'cn=Test CN,o=Test O,L=Test L,st=Test ST' ca = snakeoil_ca.SnakeoilCA(cert_path=cert_path, key_path=key_path, chain_path=chain_path, pkcs7_path=pkcs7_path, key_size=2048, subject_dn=subject_dn) subject = ca.cert.get_subject() self.assertEqual(ca.chain, crypto.dump_certificate(crypto.FILETYPE_PEM, ca.cert)) self.assertIsNotNone(ca.key) self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Test CN", subject.CN) # Make sure we preserve existing keypairs ca = snakeoil_ca.SnakeoilCA(cert_path=cert_path, key_path=key_path, chain_path=chain_path, pkcs7_path=pkcs7_path) subject = ca.cert.get_subject() self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Test CN", subject.CN)
def setUp(self): super(CertManagerTestCase, self).setUp() subject_dn = 'cn=Test CN,o=Test O,L=Test L,st=Test ST' self.ca = snakeoil_ca.SnakeoilCA(cert_path=None, key_path=None, key_size=512, subject_dn=subject_dn)
def setUp(self): super(CertManagerTestCase, self).setUp() self.ca = snakeoil_ca.SnakeoilCA(cert_path=None, key_path=None, key_size=512, subject_st='Test ST', subject_l='Test L', subject_o='Test O', subject_cn='Test CN')
def test_gen_sub_cacert_with_file_storage(self): cert_path = self.tmp_dir + 'cert.pem' key_path = self.tmp_dir + 'key.pem' chain_path = self.tmp_dir + 'cert.chain' pkcs7_path = self.tmp_dir + 'cert.p7b' subject_dn = 'cn=Test CN,o=Test O,L=Test L,st=Test ST' parent_ca = snakeoil_ca.SnakeoilCA( cert_path=cert_path, key_path=key_path, chain_path=chain_path, pkcs7_path=pkcs7_path, key_size=2048, subject_dn=subject_dn) self.assertIsNotNone(parent_ca) # create a sub-ca subject_dn = 'cn=Sub CA Test CN,o=Test O,L=Test L,st=Test ST' cert_path = self.tmp_dir + 'sub_cert.pem' key_path = self.tmp_dir + 'sub_key.pem' chain_path = self.tmp_dir + 'sub_cert.chain' pkcs7_path = self.tmp_dir + 'sub_cert.p7b' sub_ca = snakeoil_ca.SnakeoilCA( cert_path=cert_path, key_path=key_path, chain_path=chain_path, pkcs7_path=pkcs7_path, key_size=2048, subject_dn=subject_dn, parent_chain_path=parent_ca.chain_path, signing_dn=parent_ca.subject_dn, signing_key=parent_ca.key ) subject = sub_ca.cert.get_subject() self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Sub CA Test CN", subject.CN)
def test_gen_cacert_no_file_storage(self): ca = snakeoil_ca.SnakeoilCA(cert_path=None, key_path=None, key_size=512, subject_st='Test ST', subject_l='Test L', subject_o='Test O', subject_cn='Test CN') subject = ca.cert.get_subject() self.assertNotEqual(ca.key, None) self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Test CN", subject.CN)
def test_gen_cacert_no_file_storage(self): subject_dn = ('cn=Test CN,o=Test O,L=Test L,st=Test ST,ou=Test OU') ca = snakeoil_ca.SnakeoilCA(cert_path=None, key_path=None, key_size=512, subject_dn=subject_dn) subject = ca.cert.get_subject() self.assertIsNotNone(ca.key) self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Test CN", subject.CN) self.assertEqual("Test OU", subject.OU) self.assertEqual(ca.chain, crypto.dump_certificate(crypto.FILETYPE_PEM, ca.cert))
def test_gen_cacert_with_file_storage(self): cert_path = self.tmp_dir + 'cert.pem' key_path = self.tmp_dir + 'key.pem' ca = snakeoil_ca.SnakeoilCA(cert_path=cert_path, key_path=key_path, key_size=512, subject_st='Test ST', subject_l='Test L', subject_o='Test O', subject_cn='Test CN') subject = ca.cert.get_subject() self.assertNotEqual(ca.key, None) self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Test CN", subject.CN) # Make sure we preserve existing keypairs ca = snakeoil_ca.SnakeoilCA(cert_path=cert_path, key_path=key_path) subject = ca.cert.get_subject() self.assertEqual("Test ST", subject.ST) self.assertEqual("Test L", subject.L) self.assertEqual("Test O", subject.O) self.assertEqual("Test CN", subject.CN)