How to manage pkcs12 files with PHP?

Discussion in 'PHP' started by ozwolverine, Nov 21, 2006.

  1. #1
    Hello everybody,

    I need to be able to read a pkcs12 file, use the password the user enters, then extract public and private key, then use those keys for certain activities.

    I know how to read private and public keys with: openssl_pkey_get_private() and openssl_pkey_get_public(), but I tried reading a private from a p12 file but it keeps returning error. So I tried to:
    execute through command line, some linux openssl commands I know to extract the keys, like:
    openssl pkcs12 -in jgonzal.p12 -out encPrivKeyJGL.pem -nocerts -passin pass:XXXXXX

    I get error because after reading p12 with the password entered, it asks two times for the password used to encrypt the private key, I wasn't able to pass the password, so I guess what I need is a php function that could do this work for me.

    Does anyone know how to do it? Is there any class, package I can use?

    Thanks a lot,
    ozwolverine
     
    ozwolverine, Nov 21, 2006 IP