Created
December 18, 2017 04:43
-
-
Save napramirez/1c942929f5c101be89a80247f3a8617a to your computer and use it in GitHub Desktop.
Convert LetsEncrypt Certificates to PFX
This file contains hidden or 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/sh | |
# | |
# Copy of https://gist.githubusercontent.com/arichika/b1a1413b554734ae964f/raw/e657ad2dc4ddab60750d26e87add61f9b988d887/ConvertLetsPemToPfx.sh | |
# | |
pemsdir='/etc/letsencrypt/archive' # default search PEMs | |
pfxspath='/share/letsencrypt/archive' # dest of the PFXs | |
passfile='/share/letsencrypt/pass.txt' # password to be applied to the PFX file | |
for cnvifull in `find "${pemsdir}" -name 'cert*.pem' -o -name '*chain*.pem'` | |
do | |
cnvifile=${cnvifull##*/} | |
cnvinum=`echo ${cnvifile%.*} | sed -e "s#[cert|chain|fullchain]##g"` | |
cnvipkey="${cnvifull%/*}/privkey${cnvinum}.pem" | |
cnvopem=`echo ${cnvifull} | sed -e "s#${pemsdir}#${pfxspath}#g"` | |
cnvofull="${cnvopem%.*}.pfx" | |
echo "- :-) ->" | |
echo "-in ${cnvifull}" | |
echo "-inkey ${cnvipkey}" | |
echo "-out ${cnvofull}" | |
mkdir -p ${cnvofull%/*} | |
openssl pkcs12 \ | |
-export \ | |
-in ${cnvifull} \ | |
-inkey ${cnvipkey} \ | |
-out ${cnvofull} \ | |
-passout file:${passfile} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment