Created
January 21, 2012 17:18
-
-
Save presbrey/1653329 to your computer and use it in GitHub Desktop.
extends the life of an expired certificate identity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# re-self-sign id.pem|id.p12 [days] | |
# extends the life of an expired certificate identity | |
b=$(basename $1 .p12) | |
b=$(basename $b .pem) | |
days=$2 | |
# unwrap p12 to pem | |
if [ -f $b.p12 ]; then | |
(openssl pkcs12 -in $b.p12 -nodes > $b.pem) | |
fi | |
# resign pem for $days | |
if [ -f $b.pem ]; then | |
if [ -n "$days" ]; then | |
days="-days $days" | |
fi | |
(openssl x509 -in $b.pem -signkey $b.pem $days | openssl x509 -text) > $b-new.cer | |
fi | |
# copy old private key to new pem | |
if [ -f $b-new.cer ]; then | |
(cat $b-new.cer; openssl rsa -in $b.pem) > $b-new.pem | |
fi | |
# export new p12 | |
if [ -f $b-new.pem ]; then | |
(openssl pkcs12 -in $b-new.pem -export) > $b-new.p12 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment