Skip to content

Instantly share code, notes, and snippets.

@tchn
Created January 13, 2013 03:14
Show Gist options
  • Save tchn/4522053 to your computer and use it in GitHub Desktop.
Save tchn/4522053 to your computer and use it in GitHub Desktop.
generate PEM (1) client cert (2) ca cert (3) private key file from PKCS12 client cert, to be used by wget and other commandline http client.
#!/bin/sh
yourp12="$1"
clcert="${yourp12}-clcert.pem"
cacert="${yourp12}-cacert.pem"
keyfile="${yourp12}-key.pem"
echo -n "Type passphrase: "
read -s passwd
openssl pkcs12 -in "$1" -clcerts -nokeys -out "$clcert" -passin pass:"$passwd"
openssl pkcs12 -in "$1" -cacerts -nokeys -out "$cacert" -passin pass:"$passwd"
openssl pkcs12 -in "$1" -nocerts -nodes -out "$keyfile" -passin pass:"$passwd"
# wget --certificate="$clcert" --private-key="$keyfile" --ca-certificate="$cacert" https://example.com/secret/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment