Posted on 04-11-2014 02:15 PM
Thought I would share this incase anybody else needed to see if they had a certificate installed on the local machine. The variables can be set to look for a specific name of a variable and the location where it should be installed.
Tested on 10.9 & 10.8
#!/bin/bash
## Used to check for a certificate & it's location.
# VARIABLES
cert_name="certname"
desired_keychain="/Library/Keychains/System.keychain"
if [[ `security find-certificate -c "$cert_name" $desired_keychain 2>/dev/null` ]]; then
echo "<result>Installed</result>"
else
cert_search=`security find-certificate -c "$cert_name" 2>/dev/null | grep "keychain:" | awk -F """ '{ print $2 }' 2>/dev/null`
if [[ $cert_search ]]; then
echo "<result>Non-System Keychain: $cert_search</result>"
else
echo "<result>Not Found</result>"
fi
fi
exit 0
Posted on 11-20-2014 08:19 PM
Thank, Chris.
Much respect to the beard :)
Posted on 03-27-2023 04:04 AM
very useful! many thanks!