How do I extract all subjects of a cacertfile with the openssl command line?

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.


To print all subjects within CA file:

openssl crl2pkcs7 -nocrl -certfile ca-certificates.crt | openssl pkcs7 -print_certs -text -noout | grep 'Subject:'

Tags:

Ssl

Openssl