Exemplo n.º 1
0
    def test_real_certs(self):
        path = os.path.join(os.path.dirname(__file__), "data",
                            "test_certs.pem")
        with open(path) as f:
            ders = signing.extract_certs_from_pem(f.read())
        certs = [signing.parse_cert_from_der(der) for der in ders]

        # Quick spot check on the CommonName value of the subjects of the certs
        # If these are correct, the entire objects were probably parsed correctly
        assert (certs[0]["tbsCertificate"]["subject"]["rdnSequence"][4][0]
                ["value"] == b"\x13&normandy.content-signature.mozilla.org")
        assert (certs[1]["tbsCertificate"]["subject"]["rdnSequence"][3][0]
                ["value"] == b"\x13'Mozilla Signing Services Intermediate 1")
        assert (certs[2]["tbsCertificate"]["subject"]["rdnSequence"][3][0]
                ["value"] == b"\x13\x16root-ca-production-amo")
Exemplo n.º 2
0
 def test_not_a_cert(self):
     bad_data = "hello world"
     with pytest.raises(signing.CertificateParseError) as exc:
         signing.extract_certs_from_pem(bad_data)
     assert 'Unexpected input "hello world"' in str(exc.value)
Exemplo n.º 3
0
 def test_real_certs(self):
     path = os.path.join(os.path.dirname(__file__), "data",
                         "test_certs.pem")
     with open(path) as f:
         certs = signing.extract_certs_from_pem(f.read())
     assert len(certs) == 3
Exemplo n.º 4
0
 def test_incomplete_cert(self):
     bad_data = "-----BEGIN CERTIFICATE-----\nMIIGXTCCBEWgAwIBAgIEAQAACjANBgkq"
     with pytest.raises(signing.CertificateParseError) as exc:
         signing.extract_certs_from_pem(bad_data)
     assert "Unexpected end of input." in str(exc.value)
Exemplo n.º 5
0
 def test_empty(self):
     assert signing.extract_certs_from_pem("") == []