Перейти к содержанию

Как разделить cert.pem файл?

full.pem can be easily splited into cert.pem and chain.pem using grep and tail:

grep -B 1000 -m 1 -F -e "-----END CERTIFICATE-----" full.pem > cert.pem
tail -n +2 full.pem | grep -A 1000 -m 2 -F -e "-----BEGIN CERTIFICATE-----" > chain.pem

For cert.pem: search the first string -----END CERTIFICATE-----and take all before -B 1000 then output in cert.pem.

For chain.pem: skip the first line with tail -n +2 then search the first string -----BEGIN CERTIFICATE----- and take all after -A 1000 then output in chain.pem.