7 Usage: $0 <pkcs12 file> <output directory>
9 Transforms a .p12 file, for instance as exported by Firefox's
10 cerfiticate "backup" feature, into a pair of a PEM certificate file
13 To export your certificate from Firefox, go to Edit|Preferences,
14 Advanced|Security|View Certificates, and ``Backup'' your certificate
15 to a file. Firefox will save it as a PKCS12 certificate. You must
16 enter a passphrase, which this script will prompt you for.
22 [ "$#" -eq 2 ] || usage
27 echo -n "Password for $pkcs: "
33 echo "$pass" | openssl pkcs12 -in "$pkcs" -nodes -out "$outdir"/cert.pem -passin stdin
34 echo "$pass" | openssl pkcs12 -in "$pkcs" -nodes -nocerts -out "$outdir"/privkey.pem -passin stdin
37 Certificate written to $outdir/cert.pem
38 Private key written to $outdir/privkey.pem
40 Keep these files safe!
42 You can pass these to wget's --certificate and --private-key options,
43 or to curl's --cert/--key options.
45 To use them with perl's LWP, set the following environment variables:
49 outdir="$(readlink -f "$outdir")"
51 # No, this doesn't handle quoting properly.
52 echo HTTPS_CERT_FILE="$outdir/cert.pem"
53 echo HTTPS_KEY_FILE="$outdir/privkey.pem"