I need to export a .pfx format certificate (from Windows MMC) to .p12 to use in another application. I cant find a way to do this.
Can anyone suggest a method?
I need to export a .pfx format certificate (from Windows MMC) to .p12 to use in another application. I cant find a way to do this.
Can anyone suggest a method?
If you are looking for a quick and manual process with UI. I always use Mozilla Firefox to convert from PFX to P12. First import the certificate into the Firefox browser (Options > Privacy & Security > View Certificates... > Import...). Once installed, perform the export to create the P12 file by choosing the certificate name from the Certificate Manager and then click Backup... and enter the file name and then enter the password.
first We Have certificate.PFX file
Step1: (Extract Private Key)
openssl pkcs12 -in certificate.pfx -nocerts -out private.key -passin pass:123123 -passout pass:123123
Step2: (Create P12 file)
openssl pkcs12 -export -out ewallet.p12 -inkey private.key -in certificate.cer -passin pass:123123 -passout pass:123123
In my case, I wanted to import a .pfx exported from Entrust and import it into gpgsm. gpgsm did not like that PFX:
$ gpgsm --import name.pfx
gpgsm: directory '/home/me/.gnupg' created
gpgsm: keybox '/home/me/.gnupg/pubring.kbx' created
gpgsm: data error at "pkcs5PBES2-params", offset 134
gpgsm: error at "bag-sequence", offset 49
gpgsm: error parsing or decrypting the PKCS#12 file
gpgsm: total number processed: 0
Paul Chan's answer above worked (using Firefox), but I wanted a command line solution.
Inspired by the other answers, I simply tried roundtripping it using openssl pcks12, and it worked:
# Convert pfx to pem
$ openssl pkcs12 -in name.pfx -out name.pem
# Convert pem to p12
openssl pkcs12 -export -in name.pem -out name.p12
$ gpgsm --import name.p12
gpgsm: 2456 bytes of RC2 encrypted text
# ...
gpgsm: total number processed: 3
gpgsm: imported: 2
gpgsm: secret keys read: 1
gpgsm: secret keys imported: 1