mbedtls_rsa_context to pem format

Hi @mrdebug
Thank you for your question!

I believe the API mbedtls_pk_write_key_pem() answers your needs. However, this API receives mbedtls_pk_context as a parameter, and not mbedtls_rsa_context.
You will need to generate an mbedtls_pk_context from your object; You can look in other posts showing how to do this.
For example, this post also addresses your question.

Regards,
Mbed TLS support
Ron