I'd like to print the content of an RSA key created using OpenSSL and accessed by means of the pointer
RSA * rsa;
Now, I've tried to use the RSA_print and BIO_read functions as follows:
BIO * keybio ;
RSA_print(keybio, rsa, 0);
char buffer [1024];
std::string res = "";
while (BIO_read (keybio, buffer, 1023) > 0)
{
std::cout << buffer;
}
but I get a segmentation fault at the very first execution of the BIO_read (sixth line). Can someone spot the error?