Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set imported certificate to always be trusted in Mac OS X

Tags:

macos

ssl

I have generated a certificate in pfx format in Mac os X and imported it into system keychain using:

sudo security import server.pfx -k /Library/Keychains/System.keychain -P foobar

The problem is that all trusts are set to no value specified.

enter image description here

How can I set trust for code signing to Always trust using command line.

like image 823
ManiAm Avatar asked Jan 27 '16 07:01

ManiAm


People also ask

How do I always trust a certificate on my Mac?

Once it is open, navigate to the new certificate by selecting Certificates on the left side menu, then finding the certificate in the list. Once you have found the certificate, double click the certificate to load the details. Mark this as "Always Trust".

How do you set a certificate to always trust?

If the certificate doesn't seem to be immediately trusted – for example, you're receiving warnings or errors attempting to access resources – reopen "Keychain Access." Right-click the certificate and click "Get Info." Open the "Trust" menu, and under "When Using This Certificate," check "Always Trust."

Why is my certificate not trusted Mac?

You will face a root certificate not trusted error if the Securly SSL certificate is not installed on your macOS X. To stop receiving the error you would, therefore, need to install the SSL certificate. Navigate to Finder > Applications > Utilities > Keychain Access.

How do I add a trusted certificate to Apple?

If you want to turn on SSL/TLS trust for that certificate, go to Settings > General > About > Certificate Trust Settings. Under "Enable full trust for root certificates," turn on trust for the certificate. Apple recommends deploying certificates via Apple Configurator or Mobile Device Management (MDM).


2 Answers

Here's what worked for me, it's very close to that traveling beard's answer. I'm using trustAsRoot instead of trustRoot.

With this change, in the Keychain Viewer, my cert now has "Always Trust" set. When I used trustRoot, the cert is added but with "Use System Default" set and the system default is to Never Trust.

sudo security add-trusted-cert -d -r trustAsRoot -k /Library/Keychains/System.keychain <certfile>

NOTE: The sudo will prompt for a password on the commandline and the gui will also prompt.

Nice, now I can import a dev cert on the command line with only a sudo passwd and not have to open that GUI!!

like image 129
mrk Avatar answered Nov 15 '22 16:11

mrk


The -p option may be what you need. It can be specified more than once for each of the settings. I wish I knew how to deny one specific item while trusting another all in the same line.

sudo security add-trusted-cert -d -r trustRoot -p [option] -k /Library/Keychains/System.keychain <certificate>

-p options are ssl, smime, codeSign, IPSec, iChat, basic, swUpdate, pkgSign, pkinitClient, pkinitServer, timestamping, eap

like image 24
travelingbeard Avatar answered Nov 15 '22 16:11

travelingbeard