Tfe

Ongi etorri tfe-ren webgunera...

2024-08-05-ean

Ziurtagiriak: script bat PFX-tik PEM-era bihurtzeko

Gaur beste script batekin nator:
Lanean, ziurtagiriak "pfx" fixategi baten bidez eman dizkigute, baina AWSek PEM formatuak erabiltzen ditu.
Horregatik sortu nuen script bat pfx-tik pem-era fixategia bihurtzeko.

Besterrik gabe, hemen duzue scripta:

#!/bin/bash -x

echo "Enter PFX Password"
read PASSWORD

PFX=$1

if [[ "$PFX" == "" ]]
then
    echo "No PFX file provided."
fi

rm -fr cert_$PFX
mkdir cert_$PFX
echo "PASS IS $PASSWORD"

# add -legacy if needed
openssl pkcs12 -legacy -passin pass:"$PASSWORD" -passout pass:"$PASSWORD" -in $PFX -nocerts -out cert_$PFX/privatekey-$PFX.pem && \
openssl pkcs12 -legacy -passin pass:"$PASSWORD" -passout pass:"$PASSWORD" -in $PFX -clcerts -nokeys -out cert_$PFX/cert-file-$PFX.pem && \
openssl pkcs12 -legacy -passin pass:"$PASSWORD" -passout pass:"$PASSWORD" -in $PFX -cacerts -nokeys -chain -out cert_$PFX/ca-chain-$PFX.pem && \
openssl rsa -passin pass:"$PASSWORD"  -in cert_$PFX/privatekey-$PFX.pem -out cert_$PFX/withoutpw-privatekey-$PFX.pem && \
cat cert_$PFX/cert-file-$PFX.pem  cert_$PFX/ca-chain-$PFX.pem >  cert_$PFX/nginx-$PFX.crt && \

echo "CERT INFORMATION : " && \
openssl x509 -in cert_$PFX/cert-file-$PFX.pem -text

 

Tags: Linux Script