Skip to content

Instantly share code, notes, and snippets.

@gorshkov-leonid
Created August 12, 2021 22:14
Show Gist options
  • Save gorshkov-leonid/ea019d5889028fbbe17d90b815f56399 to your computer and use it in GitHub Desktop.
Save gorshkov-leonid/ea019d5889028fbbe17d90b815f56399 to your computer and use it in GitHub Desktop.
How to split PEM certificates
IN_CERTS=$(cat in.pem)
echo -e "$IN_CERTS" > ./tmp.pem 
sed -i '/^[[:space:]]*$/d' ./tmp.pem
mkdir -p _certs 
csplit -s -z -f './_certs/cert-' -b '%02d.crt' ./tmp.pem '/-----BEGIN CERTIFICATE-----/' '{*}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment