Skip to content

Instantly share code, notes, and snippets.

@larsks
Created February 10, 2024 02:26
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 larsks/f26985c4773862508ab0ac6f6556a3b6 to your computer and use it in GitHub Desktop.
Save larsks/f26985c4773862508ab0ac6f6556a3b6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Split a certificate bundle into individual certificates.
#
# This will produce files named `cert-000.crt`, `cert-001.crt`, .etc.
read -r count < <(csplit -z "$1" -f cert- -b '%03d.crt' '/^-----BEGIN CERTIFICATE-----/' '{*}' | wc -l)
echo "split $count certificates"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment