On 02/03/17 00:47, william estrada wrote: > Hello group, > I am attempting to create a Private RSA structure with the following code: > BIO* > PEM = BIO_new_mem_buf( Key, Key_Len ); > > if( Type == 1 ) > PEM_write_bio_RSAPrivateKey( PEM, RSA, NULL, NULL, 0, NULL, NULL ); > else > PEM_write_bio_RSAPublicKey( PEM, RSA ); > > if( RSA_check_key( RSA ) != 1 ) { > printf( RED "Make %s RSA Failed\n" OFF, Type==1?"Private":"Public" ); > int Error = ERR_get_error(); > char *MSG = ERR_error_string( Error, NULL); > printf( "%s\n", MSG ); } > > and I get this error: > Make Private RSA Failed > error:2007507E:lib(32):func(117):reason(126) > Can anyone tell me what this error is and how to fix it? > > $ openssl errstr 2007507E error:2007507E:BIO routines:mem_write:write to read only BIO BIO_new_mem_buf() gives you a read-only BIO. You probably want BIO_new(BIO_s_mem()) instead. See: https://www.openssl.org/docs/man1.1.0/crypto/BIO_s_mem.html Although, that error is coming from one of the PEM_write_bio_* calls (which you are not checking the error return code of), so it doesn't explain why RSA_check_key() fails. You don't show how you generate the RSA structure to start with, so I guess you're not generating it properly. Matt -- openssl-users mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users