openssl 0.9.7a problem with EVP_PKEY loading.

2005-08-02 Thread Chevalier, Victor T.
I am having trouble with openssl 0.9.7a.  I can't use a newer version
cause I am using standard redhat.

I am trying to load a private key into an EVP_PKEY using either a fp or
a BIO.

So far neither have worked.

Heres a quick example of what I'm testing.

EVP_PKEY *pkey = NULL;
BIO *in = NULL;

in = BIO_new(BIO_s_file());
BIO_read_filename(in, mykey.pem);
pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL);
if (!pkey)
{
  cout  error pkey not loading.  endl;
}
EVP_PKEY_free(pkey);
BIO_free(in);


Can someone explain why it keeps telling me error pkey not loading!!!  I
have tried this with the FILE *fp method as well.  Is there something
else I need to do, cause this is confounding me.

Thanks.
Victor
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: openssl 0.9.7a problem with EVP_PKEY loading.

2005-08-02 Thread Thomas J. Hruska

Chevalier, Victor T. wrote:

I am having trouble with openssl 0.9.7a.  I can't use a newer version
cause I am using standard redhat.

I am trying to load a private key into an EVP_PKEY using either a fp or
a BIO.

So far neither have worked.

Heres a quick example of what I'm testing.

EVP_PKEY *pkey = NULL;
BIO *in = NULL;

in = BIO_new(BIO_s_file());
BIO_read_filename(in, mykey.pem);
pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL);
if (!pkey)
{
  cout  error pkey not loading.  endl;
}
EVP_PKEY_free(pkey);
BIO_free(in);


Can someone explain why it keeps telling me error pkey not loading!!!  I
have tried this with the FILE *fp method as well.  Is there something
else I need to do, cause this is confounding me.

Thanks.
Victor


Are you sure none of the previous functions are failing?
Have you called the appropriate OpenSSL initialization calls?
Have you obtained the actual error message using standard OpenSSL error 
handlers?


I would try answering those questions in that order.  You are making a 
lot of assumptions that everything is OK right up to reading in the 
private key.  Your approach to use BIOs is the right one.  FILE pointers 
make your application non-portable.



--
Thomas Hruska
Shining Light Productions

Home of BMP2AVI, Nuclear Vision, ProtoNova, and Win32 OpenSSL.
http://www.slproweb.com/

Ask me about discounts on any Shining Light Productions product!
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]


Re: openssl 0.9.7a problem with EVP_PKEY loading.

2005-08-02 Thread Dr. Stephen Henson
On Tue, Aug 02, 2005, Chevalier, Victor T. wrote:

 
 Can someone explain why it keeps telling me error pkey not loading!!!  I
 have tried this with the FILE *fp method as well.  Is there something
 else I need to do, cause this is confounding me.
 

How about reading the FAQ?

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   [EMAIL PROTECTED]