295 {
297 if( !my ) { return ba; }
298
299 BIO *mem = BIO_new(BIO_s_mem());
300 int e = PEM_write_bio_RSAPrivateKey( mem, my->rsa, NULL, NULL, 0, NULL, NULL );
301 if( e != 1 )
302 {
303 BIO_free(mem);
304 FC_THROW_EXCEPTION( exception,
"Error writing private key, ${message}", (
"message",
fc::string(ERR_error_string( ERR_get_error(),NULL))) );
305 }
306 char* dat;
307 uint32_t l = BIO_get_mem_data( mem, &dat );
308
309
310 stringstream
ss(
string( dat,
l ) );
312 string tmp;
313 fc::getline( ss, tmp );
314 fc::getline( ss, tmp );
315
316 while( tmp.size() && tmp[0] != '-' )
317 {
318 key << tmp;
319 fc::getline( ss, tmp );
320 }
321 auto str = key.str();
324
325 BIO_free(mem);
326 return ba;
327 }
static const Segment ss(Segment::ss)
std::string base64_decode(const std::string &encoded_string)