]> snippets.scripts.mit.edu Git - Scripts/git/.git/blame_incremental - certs/pkcs2pem
kdo: Upstream krb5 now supports kswitch
[Scripts/git/.git] / certs / pkcs2pem
... / ...
CommitLineData
1#!/bin/bash
2
3set -e
4
5usage() {
6 cat <<EOF
7Usage: $0 <cert.p12> <cert.pem>
8
9Transforms a .p12 file, for instance as exported by Firefox's
10cerfiticate "backup" feature, into a PEM file that contains your
11private key and certificate.
12
13To export your certificate from Firefox, go to Edit|Preferences,
14Advanced|Security|View Certificates, and ``Backup'' your certificate
15to a file. Firefox will save it as a PKCS12 certificate. You must
16enter a passphrase, which this script will prompt you for.
17
18EOF
19 exit 1
20}
21
22[ "$#" -eq 2 ] || usage
23
24pkcs="$1"
25pem="$2"
26
27openssl pkcs12 -in "$pkcs" -nodes -out "$pem"
28
29cat >&2 <<EOF
30Private key and certificate written to $pem
31
32Keep this file safe!
33
34You can pass this to wget's --certificate and --private-key options,
35or to curl's --cert option.
36
37To use it with perl's LWP, set the following environment variables:
38
39EOF
40
41pem=$(readlink -f "$pem")
42
43printf 'HTTPS_CERT_FILE=%q\n' "$pem"
44printf 'HTTPS_KEY_FILE=%q\n' "$pem"
45