def test_dump_private_key(self): self.assertRaises(exceptions.NeedsPassphrase, cert_parser.dump_private_key, ENCRYPTED_PKCS8_CRT_KEY) self.assertEqual( UNENCRYPTED_PKCS8_CRT_KEY, cert_parser.dump_private_key(ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE)) self.assertIsNot( ENCRYPTED_PKCS8_CRT_KEY, cert_parser.dump_private_key(ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE))
def test_dump_private_key(self): self.assertRaises(exceptions.NeedsPassphrase, cert_parser.dump_private_key, ENCRYPTED_PKCS8_CRT_KEY) striped_rsa_key = _get_rsa_numbers(UNENCRYPTED_PKCS8_CRT_KEY) decrypted_rsa_key = _get_rsa_numbers( cert_parser.dump_private_key(ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE) ) self.assertEqual(striped_rsa_key, decrypted_rsa_key) self.assertIsNot( ENCRYPTED_PKCS8_CRT_KEY, cert_parser.dump_private_key(ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE), )
def test_dump_private_key(self): self.assertRaises(exceptions.NeedsPassphrase, cert_parser.dump_private_key, ENCRYPTED_PKCS8_CRT_KEY) striped_rsa_key = _get_rsa_numbers(UNENCRYPTED_PKCS8_CRT_KEY) decrypted_rsa_key = _get_rsa_numbers( cert_parser.dump_private_key(ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE)) self.assertEqual(striped_rsa_key, decrypted_rsa_key) self.assertIsNot( ENCRYPTED_PKCS8_CRT_KEY, cert_parser.dump_private_key(ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE))
def test_dump_private_key(self): self.assertRaises(exceptions.NeedsPassphrase, cert_parser.dump_private_key, ENCRYPTED_PKCS8_CRT_KEY) self.assertEqual(UNENCRYPTED_PKCS8_CRT_KEY, cert_parser.dump_private_key( ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE )) self.assertIsNot(ENCRYPTED_PKCS8_CRT_KEY, cert_parser.dump_private_key( ENCRYPTED_PKCS8_CRT_KEY, ENCRYPTED_PKCS8_CRT_KEY_PASSPHRASE ))
def _map_cert_tls_container(cert): """Map cert data to TLS data model :param cert: TLS certificate :returns: mapped TLSContainer object """ certificate = cert.get_certificate() pkey = cert_parser.dump_private_key(cert.get_private_key(), cert.get_private_key_passphrase()) return data_models.TLSContainer(primary_cn=_get_primary_cn(certificate), private_key=pkey, certificate=certificate, intermediates=cert.get_intermediates())
def _map_cert_tls_container(cert): """Map cert data to TLS data model :param cert: TLS certificate :returns: mapped TLSContainer object """ certificate = cert.get_certificate() pkey = cert_parser.dump_private_key(cert.get_private_key(), cert.get_private_key_passphrase()) return data_models.TLSContainer( primary_cn=_get_primary_cn(certificate), private_key=pkey, certificate=certificate, intermediates=cert.get_intermediates())