Big Sur Add trusted certificate via command line (Safari Can't establish a secure connection) I am trying to have Safari stop preventing me from visiting one of my dev machines with an invalid cert.
I am trying to use the solution in this thread but install it using the CLI:
   security add-trusted-cert  -r trustRoot  -k ~/Library/Keychains/login.keychain-db /tmp/test.cert

I am still receiving the &quot;Safari Can't Open the Page because Safari can't establish a secure connection to the server&quot; error.
I want it to be applied to the user so I don't want to do the -d flag.  And I know I am correctly downloading the cert because if I add the certificate and trust it through the OSX GUI, it works fine.
Another interesting note is that this solution works for my Brave and Firefox browsers, so it's just Safari that is giving me grief, but even safari works when I add the downloaded cert via the GUI.
I think answered my own question and wanted to post it here in case anyone else runs into this.  In my case not only was it a self signed cert, but I was using a local host name which did not match the hostname on the certificate.
Therefore using the following command worked for all browsers tested:
 security add-trusted-cert -e hostnameMismatch-r trustRoot -k ~/Library/Keychains/login.keychain-db newcert.pem