[openssl-users] NULL EVP_PKEY

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[openssl-users] NULL EVP_PKEY

Vollaro, John

I am having a problem reading a password protected private key file (.pem) using the OpenSSL library (programmatically).

I just get a NULL key returned.

I am using the OpenSSL 1.0.2a 19 Mar 2015 library in a Windows environment.

 

The code snippet as follows:

 

char *pemFileName = "C:\\Work\\mypemfile.pem";

       char passwordBuffer[12];

       strcpy(passwordBuffer, "pwd1234");

 

       OpenSSL_add_all_algorithms();

       BIO *bio_key = BIO_new( BIO_s_file() );

       BIO_read_filename( bio_key, pemFileName );

       EVP_PKEY *sigkey  = PEM_read_bio_PrivateKey( bio_key, NULL, NULL,(void *)passwordBuffer );

 

pemFileName is the (correct) path to the private key file.

 

I did read that calling OpenSSL_add_all_algorithms() loads OpenSSL's table of algorithms and was a fix to this issue.

In my case it has not helped.

 

Thanks for any help in soliving this issue.

 

 

John Vollaro

Phone 860.221.0129

 


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.


_______________________________________________
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] NULL EVP_PKEY

Salz, Rich
> I am having a problem reading a password protected private key file (.pem) using the OpenSSL library (programmatically).

Can you read it using the openssl command-line tool?

--  
Senior Architect, Akamai Technologies
IM: [hidden email] Twitter: RichSalz
_______________________________________________
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] NULL EVP_PKEY

Vollaro, John
It does not work using the openssl command-line tool.
I suspect that the .pem file I have only has the public key.


-----Original Message-----
From: openssl-users [mailto:[hidden email]] On Behalf Of Salz, Rich
Sent: Monday, April 20, 2015 5:25 PM
To: [hidden email]; Lichti, Richard
Subject: Re: [openssl-users] NULL EVP_PKEY

> I am having a problem reading a password protected private key file (.pem) using the OpenSSL library (programmatically).

Can you read it using the openssl command-line tool?

--
Senior Architect, Akamai Technologies
IM: [hidden email] Twitter: RichSalz _______________________________________________
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.

_______________________________________________
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: [openssl-users] NULL EVP_PKEY

Dr. Stephen Henson
On Tue, Apr 21, 2015, Vollaro, John wrote:

> It does not work using the openssl command-line tool.
> I suspect that the .pem file I have only has the public key.
>

It would help if you indicated what error you got from the openssl utility. If
the file only contains a public key it should exit immediately if it has a
private key and is encrypted it will prompt you for a passphrase.

Other problems (e.g. corrupted key) may result in ASN.1 parsing errors.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
_______________________________________________
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users