How to save an SSL certificate with a Mac

posted by 10 months ago and updated 10 months ago

Sometimes self-generated certificates from our development servers don't play as nice with our browser. So, we need to take a little extra time to configure them. We basically want to download, export the certificate and import it into your system. In order for the certificate to be trusted.

openssl s_client -connect server.com:443 -showcerts

# In case you don't have openssl install it with brew
# brew install openssl

At this point your terminal will spit out some lines with the certificates. Copy the text to text editor, including the --- Beginning and End --- and save the file as server.crt.

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

Import SSL to Keychain Access

Now, if you want to import and allow this certificate, you can double click the certificate. It will import it to your keychain with a red 'x'. You can right click the certificate in your Keychain, select Get Info and then click on Trust (with an arrow next to it). Finally, choose Always Trust under the When using this certificate.

Tags: