How to extract all subjects of a cacertfile with the openssl command line

opensslssl

Is there an openssl command to extract all certifacte subjects of a cacertfile (a file containing several certificates like /etc/ssl/certs/ca-certificates.crt)?

I tried openssl x509 -in /etc/ssl/certs/ca-certificates.crt -noout -subject but it only gives me the subject of the first certificate.

Best Answer

Unfortunately I don't believe OpenSSL can do that. OpenSSL assumes one cert per file for x509 actions.

According to this site you have to split them into individual files. He even provides a perl script that will split it for you. You could then loop over the files, or modify the perl script to extract the subject directly.