Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux/OpenSSL:Send find output to openssl

I am trying to send the output from the find command to OpenSSL in order to find out when certificates expire.

This finds the files

find . -name \*.pem -type f

This generates the cert info I want

openssl x509 -in certname.pem -noout -enddate

Can I merge these two?

Thanks for your help.

like image 954
Starsky Avatar asked Sep 20 '25 04:09

Starsky


2 Answers

find . -name \*.pem -type f -execdir openssl x509 -in {} -noout -enddate \;
like image 146
Matthew Flaschen Avatar answered Sep 21 '25 21:09

Matthew Flaschen


Just as a general comment on find: your command will run much faster if you take the output of find and pipe it to xargs and let that run the command. The problem being that find spawns a new command for each matching file and that is very slow but if you can pass multiple parameters to the same command (like xargs does) you save all those forks and context switches. It works really well with commands like grep.

like image 23
Nick Avatar answered Sep 21 '25 21:09

Nick