Ext. Attribute To List Certificates

ooshnoo
Valued Contributor

Anyone gotta quick and dirty way to collect a list of certificates from the System Keychain using a script / EA?

1 ACCEPTED SOLUTION

davidacland
Honored Contributor II
Honored Contributor II

Nothing complete unfortunately. The security command-line tool can be trickier than it first appears!

You can get the info with security find-certificate -a /Library/Keychains/System.keychain but it will take a bit of cleaning up to make it useful.

Something like this seems to work: security find-certificate -a /Library/Keychains/System.keychain | grep "alis" | sed 's/"//g' | sed 's/ alis<blob>=//g'

Or in EA format:

certs=$(security find-certificate -a /Library/Keychains/System.keychain | grep "alis" | sed 's/"//g' | sed 's/    alis<blob>=//g')
echo "<result>$certs</result>"

View solution in original post

4 REPLIES 4

davidacland
Honored Contributor II
Honored Contributor II

Nothing complete unfortunately. The security command-line tool can be trickier than it first appears!

You can get the info with security find-certificate -a /Library/Keychains/System.keychain but it will take a bit of cleaning up to make it useful.

Something like this seems to work: security find-certificate -a /Library/Keychains/System.keychain | grep "alis" | sed 's/"//g' | sed 's/ alis<blob>=//g'

Or in EA format:

certs=$(security find-certificate -a /Library/Keychains/System.keychain | grep "alis" | sed 's/"//g' | sed 's/    alis<blob>=//g')
echo "<result>$certs</result>"

ooshnoo
Valued Contributor

Thanks David! Seems to do the trick!

mm2270
Legendary Contributor III

Slightly shorter way, but same principle:

security find-certificate -a /Library/Keychains/System.keychain | awk -F'"' '/alis/{print $4}'

bjones
New Contributor III

@davidacland David hey i am no script writer by any means and i am trying to take the EA you provided which worked by the way to see if i can get a specific profile instead a list of every one. Also maybe be able to have the EA confirm "yes" or "no" to display for the EA.