Skip to content

Instantly share code, notes, and snippets.

@mjdetullio
Created November 17, 2015 19:13
Show Gist options
  • Save mjdetullio/592239b0fe3988a7e6ad to your computer and use it in GitHub Desktop.
Save mjdetullio/592239b0fe3988a7e6ad to your computer and use it in GitHub Desktop.
OS X: Verify all certificates in a keychain
#!/bin/bash -xe
KEYCHAIN="~/Library/Keychains/login.keychain"
TMPFILE="$(mktemp)"
security find-certificate -a "${KEYCHAIN}" | grep '"alis"<blob>=' | sed -e 's/^ "alis"<blob>="\(.*\)"$/\1/' | while read -r CERT_NAME
do
security find-certificate -c "${CERT_NAME}" -p "${KEYCHAIN}" > "${TMPFILE}"
security verify-cert -c "${TMPFILE}" -k "${KEYCHAIN}"
done
@poornimakuddalli
Copy link

poornimakuddalli commented Feb 7, 2023

It gives no output if I run the above shell script, could you please help me to make it work.
I tried echo ${TMPFILE} and got "var/folders/vq/wfgn1p4j74v467wr8dmgt33r0000gq/T/tmp.mkmje0UQ" path
When I did cd to above path tmp.mkmje0UQ give me nothing (an empty file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment