How to add a self-signed root CA and always trust it from CLI on OSX

Solution 1:

It seems that the only way to modify the trust settings via the security command is by the trust-settings-import option. The xml file output by security trust-settings-export would be a good place to start; but, it looks a little tricky.

Solution 2:

Probably your root CA certificate is malformed, as your method works for me. Maybe your CA root certificate has not been generated with the expected properties. Try with -r trustAsRoot in your case, but I recommend to check your certificate generation.