[openssl-users] Convert RSA key string to PEM file.

Sugumar sugu.ece28 at gmail.com
Sat Jan 2 04:36:54 UTC 2016

Ya your example looks good. Thanks.
And i have another method, i have created BIO by passing that key to
BIO_new_mem_buf function then from that BIO i got a RSA structure using
PEM_read_bio_RSAPublicKey function.

Is that will work for me???


RSA* CreateRSAStruct(void* data, GetKey type)
    RSA *rsa= NULL;
    BIO *rsaKeyBio;
    rsaKeyBio = BIO_new_mem_buf(data, -1); //creates read only memory BIO

    if (rsaKeyBio==NULL)
        std::cout<< "Failed to create key BIO" <<std::endl;
        return NULL;
        rsa = PEM_read_bio_RSAPublicKey(rsaKeyBio, &rsa,NULL, NULL);
        rsa = PEM_read_bio_RSAPrivateKey(rsaKeyBio, &rsa,NULL, NULL); 

    return rsa;

View this message in context: http://openssl.6102.n7.nabble.com/Convert-RSA-key-string-to-PEM-file-tp61971p61977.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.

More information about the openssl-users mailing list