Hi, 
I'm trying to get a privatekey from a PKCS12 file. I found an interesting
example with the sources of OpenSSL in DEMO\PKCS12\pkread.c

I'm working under windows NT4 pack 5 with Visual C++, and I'm having some
trouble having the example work.

At the line     p12 = d2i_PKCS12_fp(fp, NULL);
I have the following error:
    Unhandeled exception in pkread.exe (NTDLL.DLL): 0xC00000005: Access
Violation

My file and my password are valide.

here the beginning of the code : 

int main(int argc, char **argv)
{
        FILE *fp;
        EVP_PKEY *pkey;
        X509 *cert;
        STACK_OF(X509) *ca = NULL;
        PKCS12 *p12;
        int i;

        if (argc != 4) {
                fprintf(stderr, "Usage: pkread p12file password opfile\n");
                exit (1);
        }
        SSLeay_add_all_algorithms();
        ERR_load_crypto_strings();
        if (!(fp = fopen(argv[1], "rb"))) {
                fprintf(stderr, "Error opening file %s\n", argv[1]);
                exit(1);
        }
        i = NULL;
        p12 = d2i_PKCS12_fp(fp, NULL);  // ERROR
        fclose (fp);
        ...


Thanks


David Vergin - EPITA Promo 2002
[EMAIL PROTECTED]
[EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to