Hi!
I have a public file in PEM format generated by:
openssl genrsa -f4 -out key.pem 1024
openssl rsa -in key.pem -pubout >pub.pem
When I try to read this key with the following code:
FILE *fp = fopen( "pub.pem", "r" );
RSA *pubKey = NULL;
ERR_load_crypto_strings();
if ( PEM_read_RSAPublicKey( fp, &pubKey, NULL, "" ) == NULL ) {
cerr << "Error reading public key." << endl;
long error = ERR_get_error();
while ( error != 0 ) {
char buffer[ 120 ];
ERR_error_string( error, buffer );
cerr << buffer << endl;
error = ERR_get_error();
}
}
I always get the following error:
Error reading public key.
error:0906D06C:PEM routines:PEM_read_bio:no start line
Anyone knows what I might be doing wrong?
Thank you!
--
Filipe Custódio
Technical Architect
e-Trust Unit
Novabase