Splitting Certificate chain

Here is how one can split a certificate chain into individual files .
sure this can be done manualy in any text editor , but there comes a time when … well
such simple task may consume a lot of time . here are 2 examples how you can do it :
Method 1 :

cat $file|awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > "mycert" n ".pem"}'

Method 2 :

csplit -k -f mycert $file '/END CERTIFICATE/+1' {*}