Error while loading the RSA private key file to generate CSR

I generated RSA public and private key pair and now I am trying to generate CSR in ESP32 following

I am getting an error while trying to load the private key file in pk context using mbedtls_pk_parse_keyfile() as in this
This return an error -15616. I checked the private key file by printing the key value and the path of private keyfile. I set the password as NULL.
Has anyone come across this issue or know what this error means? Could anyone of you please help or guide me how to solve this?
Any help is appreciated.

Thank you

Mbed TLS has a utility function in programs/ustil/strerror that will print the error code you are receiving in a string format.
You will see:

./strerror  -15616
Last error was: -0x3d00 - PK - Invalid key tag or value

This usually means that that the key file you are using doesn’t have a format that Mbed TLS supports.
Is it possible the key is not in PKCS8 or PKCS1 format?
Mbed TLS Team member