Arm Mbed and Pelion device management support forum

Parse CERT.RSA to get public key

Hi, I am android developer, I want to extract the public key from CERT.RSA which is stored in APK file.
I tried using mbedtls_x509_crt_parse, I get -8674 error code from x509_crt_parse_der_core.
Please help.

Hi @amit2008kashu
mbedtls_x509_crt_parse() can receive a PKCS#1 or PKCS#8 certificate, in PEM or DER format.
The CERT.RSA is not in the accepted format.
Looking at this post, you may consider doing the following:

openssl pkcs7 -in CERT.RSA -inform DER -out cert.pem

After that, you can you should send the content of cert.pem to mbedtls_x509_crt_parse()
Regards,
Mbed TLS Support
Ron