I am trying to create a certificate in python that was previously built using the openssl ca
command. Everything works flawless except one thing: I need to add the "nsCertType" extension, which seems to be deprecated. However, I could not find a way to add arbitrary certificate extensions. This guy is asking the same question for go, and even specifies a solution for python using OpenSSL, however I can not figure out how to do it without OpenSSL. Here is my code:
inter_server_cert = x509.CertificateBuilder().subject_name(
subject
).issuer_name(
inter_ca_cert.issuer
).public_key(
inter_server_key.public_key()
).serial_number(
x509.random_serial_number
).not_valid_before(
datetime.datetime.utcnow()
).not_valid_after(
datetime.datetime.utcnow() + datetime.timedelta(days=duration_rootca)
).add_extension(
x509.BasicConstraints(
ca=False, path_length=0
),
critical=True
).add_extension(
x509.SubjectKeyIdentifier.from_public_key(inter_server_key.public_key()),
critical=False
).add_extension(
x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier(authority_key_identifier.value),
critical=False
).add_extension(
x509.KeyUsage(
key_cert_sign=False,
crl_sign=False,
digital_signature=True,
content_commitment=False,
key_encipherment=True,
data_encipherment=False,
key_agreement=True,
encipher_only=False,
decipher_only=False
),
critical=False
).add_extension(
x509.ExtendedKeyUsage([x509.oid.ExtendedKeyUsageOID.SERVER_AUTH]),
critical=False
).sign(inter_ca_key, hashes.SHA256(), default_backend())