Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PEM_read_bio_PrivateKey returns NULL

1,316 views
Skip to first unread message

Jan

unread,
Mar 6, 2012, 10:30:12 AM3/6/12
to
Hi,
I'm simply trying to read a private key from a 3DES encrypted pem key file but the PEM_read_bio_PrivateKey returns null.

> const char *file = "/tmp/priv.key";
> const char *pass = "123456";
>
> BIO *key BIO_new(BIO_s_file());
> if(key == NULL) {
> ...
> }
>
> if (BIO_read_filename(key,file) <= 0)
> ...
> }
>
> pkey = PEM_read_bio_PrivateKey(key, NULL, 0, pass);
> if (pkey == NULL)
> {
> BIO_printf(err, "unable to load signing key\n");
> }
>

The file does exists and the pin is correct but the pkey is all the time null. What am I doing wrong ?

I'm using OpenSSL 1.0 API

regards,
Jan

Jan

unread,
Mar 7, 2012, 6:30:10 AM3/7/12
to
So I'm debugging the openssl code and I see that PEM_get_EVP_CIPHER_INFO calls EVP_get_cipherbyname(p).

p is in my key "DES-EDE3-CBC" and the cipherbyname returns null. Does it mean that this cipher is not supported ? If so, why my openssl (1.0.0e) binary can load the private key ? It is the same version as my api libs.

regards,
Jan

Jan

unread,
Mar 7, 2012, 7:57:35 AM3/7/12
to
0 new messages