Esempio n. 1
0
 def setUp(self):
     """Set up CertificateSigningRequestBuilder."""
     self.proto = load_csr(TestSubject.config)
     self.proto.key_info.key_path = (
         TestCertificateSigningRequest.create_rsa_key_file()
     )
     self.builder = x509.CertificateSigningRequestBuilder()
     self.builder = self.builder.subject_name(Subject.from_proto(self.proto.subject))
Esempio n. 2
0
def test_extension():
    """Test all extensions in example config."""
    proto = load_csr(example_extension_config)

    for extension in proto.extensions:
        extval = Extension.from_proto(extension)

        assert isinstance(
            extval, x509.extensions.ExtensionType
        ), f"Correct {extension} should inherit from x509 ExtensionType"
Esempio n. 3
0
    def setUp(self):
        """Set up a backend."""
        csr = load_csr(TestSubject.config)
        csr.key_info.key_path = TestCertificateSigningRequest.create_rsa_key_file()

        builder = x509.CertificateSigningRequestBuilder()
        self.builder = builder.subject_name(Subject.from_proto(csr.subject))

        self.signing_key = SigningKey._from_path(csr.key_info.key_path, csr.hash_type)
        self.backend = MyBackend()
Esempio n. 4
0
    def setUp(self):
        """Set up a CertificateSigningRequest."""
        proto = load_csr(TestSubject.config)
        proto.output_path = NamedTemporaryFile().name

        proto.key_info.key_type = KeyType.RSA
        self.rsa_csr = CertificateSigningRequestBuilder.from_proto(proto)
        self.rsa_private_key = rsa.generate_private_key(
            public_exponent=65537, key_size=2048
        )

        proto.key_info.key_type = KeyType.DSA
        self.dsa_csr = CertificateSigningRequestBuilder.from_proto(proto)
        self.dsa_private_key = dsa.generate_private_key(
            key_size=2048,
        )

        proto.key_info.key_type = KeyType.EC
        self.ec_csr = CertificateSigningRequestBuilder.from_proto(proto)
        self.ec_private_key = ec.generate_private_key(
            ec.SECP256R1(),
        )
Esempio n. 5
0
 def setUp(self):
     """Set up for a Subject."""
     self.proto = load_csr(self.config)