Hi Felipe,
I don't think that's possible with Mbed TLS 3.0, but it was possible with Mbed TLS 2.x and will be possible again in Mbed TLS 3.1: you can access the DER representation of the certificate from the raw field of the mbedtls_x509_crt structure. A simple call to memcpy() should to the trick.
If you want to ouput it as PEM, I think you'll have to call `mbedtls_pem_write_buffer()` manually with appropriate values for header and footer.
Regards, Manuel. ________________________________ From: mbed-tls mbed-tls-bounces@lists.trustedfirmware.org on behalf of Felipe Gasper via mbed-tls mbed-tls@lists.trustedfirmware.org Sent: 01 December 2021 21:02 To: mbed-tls@lists.trustedfirmware.org mbed-tls@lists.trustedfirmware.org Subject: [mbed-tls] Output a mbedtls_x509_crt?
Hello,
Is it possible to output a mbedtls_x509_crt as PEM or DER? I’ve been combing the API docs but don’t see how I can do this export. I see controls for exporting a newly-built cert, but not one that comes from, e.g., mbedtls_ssl_get_peer_cert().
Thank you!
Cheers, -Felipe Gasper -- mbed-tls mailing list mbed-tls@lists.trustedfirmware.org https://lists.trustedfirmware.org/mailman/listinfo/mbed-tls