Example #1
0
    def testItShouldLoadACA(self):
        old_ca = CA()
        old_ca.create_ca()

        key_pem = CA.pkey_to_pem(old_ca.ca_key)
        cert_pem = CA.certificate_to_pem(old_ca.ca_cert)

        ca = CA()
        assert ca.load(key_pem, cert_pem)
Example #2
0
    def testItShouldHaveACAAfterLoading(self):
        old_ca = CA()
        old_ca.create_ca()

        key_pem = CA.pkey_to_pem(old_ca.ca_key)
        cert_pem = CA.certificate_to_pem(old_ca.ca_cert)

        ca = CA()
        ca.load(key_pem, cert_pem)

        assert ca.has_ca()
Example #3
0
    def testItShouldNotLoadACAFromInvalidKeyMaterial(self):
        old_ca = CA()
        old_ca.create_ca()

        key_pem = CA.pkey_to_pem(old_ca.ca_key)

        old_ca.create_ca()

        cert_pem = CA.certificate_to_pem(old_ca.ca_cert)

        ca = CA()
        assert not ca.load(key_pem, cert_pem)
        assert not ca.has_ca()
Example #4
0
    def testItShouldSerializeAPrivateKeyToPEM(self):
        ca = CA()
        ca.create_ca()

        assert CA.pkey_to_pem(ca.ca_key).find(b"PRIVATE KEY") >= 0