Here's the code I use:

 EVP_PKEY* GetPrivateKey(char *fileName, char *pass)
 {
     FILE *f;
     PKCS12 *p12;
     X509_NAME *name;
     X509 *certificato;
     EVP_PKEY *privata; // = new EVP_PKEY();
     int len = strlen(pass);
     if ((f = fopen(fileName, "r")) == NULL)
  throw HandledError("File Specified Could Not Be Read");
     else {
  if (!(p12 = d2i_PKCS12_fp(f, NULL)))
      throw
   HandledError("File Specified is not a valid PKCS12 File");
  else {
      fclose(f);
      if (!PKCS12_parse
   (p12, pass, &privata, &certificato,
    NULL)) throw HandledError("Wrong Password");

      PKCS12_free(p12);
      return privata;
  }
     }
 }

It returns a private key from a X509 certificate.
Hope this helps.
Sincerely,
Andrea Nagar

  lidia castillejo marco <[EMAIL PROTECTED]> wrote:

I use function
PEM_read_PrivateKey(f, NULL, keyPwdCallback, (void*)keyPwd) where keyPwdCallback=NULL
to load private key.
If the private key is protected with password(using rc4 or 3des encryption) i cannot load the key.
Some idea?
I'm using openssl 0.9.7 (openssl-0.9.7-stable-SNAP-20020505.tar.gz)

Thanks,
lidia
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]



Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup

Reply via email to