I'm using openssl library and I want to read a public key from a .pem file with BIO. I tried this, but my rsa variable remains uninitialized :
RSA *rsa = RSA_new();
BIO *keybio = NULL;
keybio = BIO_new(BIO_s_file());
BIO_read_filename(keybio, "public.pem");
// and also tried this instead of last two lines:
// keybio = BIO_new_file("public.rem", "r");
rsa = PEM_read_bio_RSA_PUBKEY(keybio, &rsa, NULL, NULL);
When I debug my application it shows me something like this:
rsa { padding = ???, n = ??? , ...}
rsa->n <unable to read from memory> and so on for all rsa fields.
My file is valid and the key is generated respecting PKCS#1 format. I parsed it with an asn1 parser.