1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-23 00:25:18 +00:00

Clean up PKCS#12 generation

This commit is contained in:
Lauri Võsandi 2017-02-09 17:02:02 +00:00
parent dae282973e
commit 4eed940a66

View File

@ -235,19 +235,9 @@ def generate_pkcs12_bundle(common_name, key_size=4096, owner=None):
)
csr = x509.CertificateSigningRequestBuilder().subject_name(x509.Name([
x509.NameAttribute(k, v) for k, v in (
(NameOID.COMMON_NAME, common_name),
) if v
x509.NameAttribute(NameOID.COMMON_NAME, common_name)
]))
if owner:
click.echo("Setting e-mail to: %s" % owner.mail)
csr = csr.add_extension(
x509.SubjectAlternativeName([
x509.RFC822Name(owner.mail)
]),
critical=False)
# Sign CSR
cert = sign(Request(
csr.sign(key, hashes.SHA512(), default_backend()).public_bytes(serialization.Encoding.PEM)), overwrite=True)