Using shell script to delete all matching certificates.
I found a list of certificates using:
security find-certificate -c "certificatename" -a -Z|grep SHA-1|awk '{ print $NF }'
Output is like this:
$ bash delete-cert.sh
62D58774F9329FA1F96A2BB0C090130305B879ED
94B149CFDF32BDB1C9C28179FB586291167EC235
Now, I want to run the delete command on each of those SHA-1
hashes, how can I do that?
sudo security delete-certificate -Z hash
I was doing like this,
hashes=$(security find-certificate -c "certificatename" -a -Z|grep SHA-1|awk '{ print $NF }')
for hash in $hashes; do
echo deleting $hash
sudo security delete-certificate -Z $hash
done
But I like the one line solution by #chaos