Safari and accessing an HTTPS site behind a web proxy

Safari, unlike FireFox and Chrome, will not let you access a web site behind a proxy server if that site has an untrusted SSL certificate. Safari will ask you to login into the proxy server and then, after some time, tell you it can't access the site. The way I found around this to to import the untrusted certificate directly into the OS X's keychain using Keychain Access. The steps I used are

1. Use FireFox to initially access the site and to accept the untrusted certificate.

2. Use FireFox's certificate manager at ForeFox / Preferences... / Advanced / Encryption / View Certificates to export the certificate. Use the PEM encoding and make sure to name the file with a ".pem" extension.