Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bobotech

macrumors newbie
Original poster
Sep 29, 2011
21
0
I'm trying to write a script that will import a certificate into a user's keychain, and then force it to be trusted. The certificate by default is untrusted since its a self signed cert.

First command for the cert is this:
Code:
sudo -u $USERNAME /usr/bin/security import /Users/Shared/OurCert.cer -k /Users/$USERNAME/Library/Keychains/login.keychain
That part works fine, the cert is now in the user's keychain but is untrusted.

Next command is this:
Code:
sudo -u $USERNAME /usr/bin/security add-certificates /Users/Shared/OurCert.cer
I assume that this is working, no error is thrown on that line.

The final command for the cert is this:
Code:
sudo -u $USERNAME /usr/bin/security add-trusted-cert /Users/Shared/OurCert.cer
If I do the command in terminal, it prompts for the admin username/pass which is fine but when I hit okay, i get no errors and the command prompt but the cert is still untrusted in Keychain app.

What am I missing?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.