Uncle Deadly Image

Hi there. Welcome to blog.oddbit.com! I post articles here on a variety of technical topics. Mostly I’m posting for myself (writing things up helps me remember them in the future), but I always hope the content I put here is helpful to someone else. If you find something here useful and want to say thanks, feel free to buy me a coffee!

Split concatenated certificates with awk

This script expects a list of concatenated certificates on input and

produces a collection of individual numbered files each containing

a single certificate.

BEGIN {incert=0}

/—–BEGIN( TRUSTED)? CERTIFICATE—–/ { certno++ certfile=sprintf("cert-%d.crt", certno) incert=1 }

/—–END( TRUSTED)? CERTIFICATE—–/ { print >> certfile incert=0 }

incert==1 { print >> certfile }

read more →