Support to convert certificate from pfx to pem format (#5073)
* Support to convert certificate from pfx to pem format * Fix code issue
This commit is contained in:
parent
d24d717982
commit
81e0777b47
34
scripts/convert-pfx-cert-format.sh
Executable file
34
scripts/convert-pfx-cert-format.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash -ex
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "Usage: $0 -p <pfx_cert> -k <signing_key> -c <signing_cert> -a <ca_cert>"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "p:k:c:a:" opt; do
|
||||||
|
case $opt in
|
||||||
|
p)
|
||||||
|
PFX_FILE=$OPTARG
|
||||||
|
;;
|
||||||
|
k)
|
||||||
|
SIGNING_KEY=$OPTARG
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
SIGNING_CERT=$OPTARG
|
||||||
|
;;
|
||||||
|
a)
|
||||||
|
CA_CERT=$OPTARG
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
( [ -z $PFX_FILE ] || [ -z $SIGNING_KEY ] || [ -z $SIGNING_CERT ] || [ -z $CA_CERT ] ) && exit 1
|
||||||
|
|
||||||
|
openssl pkcs12 -in "${PFX_FILE}" -clcerts -nokeys -nodes -passin pass: | sed -z -e "s/.*\(-----BEGIN CERTIFICATE\)/\1/" > ${SIGNING_CERT}
|
||||||
|
openssl pkcs12 -in "${PFX_FILE}" -nocerts -nodes -passin pass: | sed -z -e "s/.*\(-----BEGIN PRIVATE KEY\)/\1/" > ${SIGNING_KEY}
|
||||||
|
openssl pkcs12 -in "${PFX_FILE}" -cacerts -nokeys -nodes -passin pass: | sed -z -e "s/.*\(-----BEGIN CERTIFICATE\)/\1/" > ${CA_CERT}
|
Reference in New Issue
Block a user