Skip to content

Instantly share code, notes, and snippets.

@clayrisser
Last active April 2, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayrisser/f521fe54c8982c760e25b14ee934eb61 to your computer and use it in GitHub Desktop.
Save clayrisser/f521fe54c8982c760e25b14ee934eb61 to your computer and use it in GitHub Desktop.
Extract cert.pem and fullchain.pem from tls.crt
cat tls.crt | base64 -d | tr '\n' '~' | \
sed 's/-\+END CERTIFICATE-\+~-\+BEGIN CERTIFICATE-\+/~/g' | \
awk '{split($0,array,"~~~")} END{print array[1]}' | tr '~' '\n' > cert.pem
echo "-----END CERTIFICATE-----" >> cert.pem
echo >> cert.pem
echo "-----BEGIN CERTIFICATE-----" > fullchain.pem
cat tls.crt | base64 -d | tr '\n' '~' | \
sed 's/-\+END CERTIFICATE-\+~-\+BEGIN CERTIFICATE-\+/~/g' | \
awk '{split($0,array,"~~~")} END{print array[2]}' | tr '~' '\n' >> fullchain.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment