X-Git-Url: https://snippets.scripts.mit.edu/gitweb.cgi/Scripts/git/.git/blobdiff_plain/6e450839636f61d14809461d59f75a62b690f41a..refs/heads/master:/certs/pkcs2pem diff --git a/certs/pkcs2pem b/certs/pkcs2pem index deda4ee..513b32e 100755 --- a/certs/pkcs2pem +++ b/certs/pkcs2pem @@ -1,14 +1,14 @@ -#!/bin/sh +#!/bin/bash set -e usage() { cat < +Usage: $0 Transforms a .p12 file, for instance as exported by Firefox's -cerfiticate "backup" feature, into a pair of a PEM certificate file -and private key. +cerfiticate "backup" feature, into a PEM file that contains your +private key and certificate. To export your certificate from Firefox, go to Edit|Preferences, Advanced|Security|View Certificates, and ``Backup'' your certificate @@ -22,33 +22,24 @@ EOF [ "$#" -eq 2 ] || usage pkcs="$1" -outdir="$2" +pem="$2" -echo -n "Password for $pkcs: " -stty -echo -read pass -stty echo -echo - -echo "$pass" | openssl pkcs12 -in "$pkcs" -nodes -out "$outdir"/cert.pem -passin stdin -echo "$pass" | openssl pkcs12 -in "$pkcs" -nodes -nocerts -out "$outdir"/privkey.pem -passin stdin +openssl pkcs12 -in "$pkcs" -nodes -out "$pem" cat >&2 <