subject = Name([
x509.NameAttribute(NameOID.COMMON_NAME, oid),
])
csr = x509.CertificateSigningRequestBuilder().subject_name(
subject
).sign(private_key, hashes.SHA256(), default_backend())
# Sign the CSR with the CA private key. The ( ) allows
user_certificate = (
x509.CertificateBuilder()
.subject_name(csr.subject)
.issuer_name(subject)
.public_key(csr.public_key())
.serial_number(x509.random_serial_number())
.not_valid_before(datetime.datetime.utcnow())
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=days))
.sign(ca_private_key, hashes.SHA256(), default_backend())
)
authorized_key = user_certificate.public_bytes(
encoding=serialization.Encoding.PEM,
)
The only encoding that is allowed is PEM, and no formatting is allowed.
I’ve tried getting the public_key() from user_certificate, and formatting it with public_bytes(), but that just gave me a ssh-rsa algorithm key (no cert).
If this is the correct path to get what I want, how do I get this into an encoding/format for OpenSSH?
Thanks,
John