Unable to accept self-signed certificate in Safari 11 to access Vagrant / Homestead local site

I installed Vagrant and Homestead to test my application locally. Everything works correctly when I access http://mysite.app in Firefox and Chrome. However, Safari will not allow me to use the http / unsafe version of the site and will automatically redirect me to the secure (https) version. For example, when accessing http://mysite.app , I redirect to https://mysite.app .

Other browsers (Firefox and Chrome) do not redirect me, and I can use the standard, insecure version. Therefore, this is not a server redirect.

Redirecting in itself will not be a problem if Safari allows me to access the https version. Since this is a local environment for developers, the SSL certificate itself is signed, and Safari does not allow me to access the site with the certificate without trusted certificates. So in the end, I always get the Safari can't establish a secure connection error when using Safari to access this vagrant site.

Results Page

Safari does not offer a way (anymore?) To accept the self-signed certificate. Again, this is not a problem with Chrome or Firefox, as they allow you to add an exception directly from the browser.

Any idea how I can get Safari to use the http version of the site, or get Safari to trust a self-signed certificate?

FYI, I am using Safari 11.0.2 on the High Sierra 10.13.2 Beta. The same result on iMac and MacbookAir, so it is not connected to the computer.

+5
source share
1 answer

Until I found why Safari wants to force SSL and doesn’t want to use the unsafe (http) version of my site in this Vagrant / Homestead field (like Firefox or Chrome), I found a way to mark the site’s self-signed certificate as trusted in accessing Keychain for MacOS .

Please note that this should not be a problem with the previous version of MacOS, since Safari allows you to add an exception directly to the browser and continue to work with the site with an invalid SSL certificate. These seam options will disappear in Safari 11 (High Sierra).

So, the solution for accessing my vagrant website is to save the website certificate on the host computer (using an ssh connection to the Vagrant mailbox or another browser), add this to the Keychain and mark it as trusted.

However, there was another issue related to Keychain Access. While it was used to work on an earlier version of MacOS, in High Sierra (or at least 10.13.2 Beta), the ability to mark a certificate as trusted from the Keychain Access application has been removed . On both the iMac and MacbookAir, double-clicking on the certificate added to Keychain does absolutely nothing . Even clicking Get Info from the context menu does not allow editing the certificate.

A workaround for this is to use the command line to mark the certificate as trusted. Using Terminal, cd to the directory where the certificate is stored on your computer and run the following command:

 sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain example.app.cer 

Change example.app.cer to the name of your certificate. This will mark the certificate as trusted in Keychain Access and allow you to visit the local site as if it were signed with a valid certificate.

tl; dr Add the site certificate, taken from the Vagrant / Homestead box, to the key chain, run the command and just use the https link.

+3
source

Source: https://habr.com/ru/post/1273643/


All Articles