Hi,
We have a Configuration Profile pushing out our WiFi settings with certs currently, but recently the first batch started expiring. They get renewed, no problem, but the expired cert is left in the keychain.
I'm trying to script the removal of them using the following script, so they can't be selected for the wireless profile.
#!/bin/bash
# Grabs the expired certificate hashes
expired=$(security find-identity | grep EXPIRED | awk '{print $2}')
# Check for certs
if [ -z "$expired" ]
then
echo "No expired certificates, we're all good"
else
# Deletes the expired certs via their hash
echo "Deleting expired certs"
security delete-certificate -Z $expired
fi
exit 0 #success
If I run these commands locally on the machine, then it works no problem, but via a policy it always fails with:
'Unable to delete certificate matching "XXXXXXXX..."
Any thoughts? Is there a better way to manage certificates for WiFi profiles?
Thanks
Chris