1

How do i convert DER formated X.509 certificate to PEM form using MbedTLS? Actually the certificate which i'm recieving is in BASE64 encoded , while performing BASE64 decoding it gives DER formated certificate, but i require PEM format and want to covert the obtained DER format certificate to PEM using MbedTLS.

LIJIN T V
  • 81
  • 8

1 Answers1

1

There is mbedtls_pem_write_buffer. But as you need to specify your header and footer yourself, so it won't be doing much if your data is already base64 encoded. However, PEM also requires some specific base64 with line endings included, so I'd still use this function. Otherwise you just need to add the right BEGIN CERTIFICATE and END CERTIFICATE header & footer lines.

The API call docs are a bit sparse, so I'd just experiment and then use openssl x509 -in cert.pem to test.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263