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??? Code: 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; } if(type) rsa = PEM_read_bio_RSAPublicKey(rsaKeyBio, &rsa,NULL, NULL); else rsa = PEM_read_bio_RSAPrivateKey(rsaKeyBio, &rsa,NULL, NULL); BIO_free(rsaKeyBio); 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.