How to trust an invalid certificate in Big Sur / Safari 14

Note: Don't do this for sites you don't trust!

This might not be the simplest solution, but it's the only one I could come up with (thanks to https://serverfault.com/questions/139728/how-to-download-the-ssl-certificate-from-a-website# for explaining how to download the certificate). Assuming we want to trust https://test.com/

  1. Download the certificate by running this in the Terminal:
echo -n | openssl s_client -connect test.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/test.cert
  1. Add it to your Keychain
open /tmp/test.cert
  1. Add it to the System Keychain

Add it to the System Keychain

  1. Find it in the Keychain, double-click it and trust it:

Trust the certificate