Managing a Local site’s SSL certificate in macOS

A screenshot of Local on the Site Overview page and with the SSL certificate trusted.

In most cases, Local makes it easy to get your offline development environment running HTTPS by providing a one-click solution for trusting a site’s SSL certificate.

Occasionally, if that “trust” process doesn’t work, you’ll need to manually let your Mac know that it can trust the Local site’s certificate.

note

MacOS BigSur doesn’t allow Local to automatically trust an SSL certificate.

Right now, the only way for BigSur users to work with a Local site over HTTPS is to manually trust the SSL certificate following the steps below.

We know this is annoying and are exploring alternative ways that Local can make this process easier.

Step 1: Create the certificate with Local

The first thing to do is click the “Trust” button next to the “SSL” section of the “Site Overview” page.

Even if this isn’t working in terms of getting the site to load over HTTPS, clicking the button directs Local to generate a certificate with the correct information about this site and attempt to register the certificate with macOS.

Clicking the “Trust” button so that Local can generate and register the certificate with the system.

Step 2: Keychain Access

In macOS, most secrets are stored in “Keychains.” This includes things like passwords, ssh keys, and importantly for us, SSL certificates.

Using the “Keychain Access” application that comes with macOS, we can search for the SSL certificate that Local created. Once found, you can manage all sorts of settings for that specific certificate.

In our case, we want to update the “When using this certificate” setting from “Use System default” to “Always Trust“. This means that for this certificate, for this site, macOS will always trust the connection and stop annoying you with warnings about the certificate.

A screenshot of finding and launching the Keychain Access application using Finder or Alfred.
The “Keychain Access” application can be found in the /Applications folder or by searching with an application launcher like Spotlight or Alfred.
A screenshot of the Keychain Access application and manually updating the setting to have MacOS Always Trust the Local site's certificate.
Search for the Local site’s domain and instruct the system to “Always Trust” the certificate.
The whole process of creating the certificate and manually setting it to be “Always Trusted” within the Keychain Access app.

Set 3: Verify the certificate is trusted

Now that the certificate is set to “Always Trust,” how can you verify that everything is working?

Open the site in a browser again and ensure that there is a ‘lock’ in the address bar. If the lock is missing, the first thing to check is if the address bar has https:// at the beginning of the domain.

Verifying that the certificate is trusted in the browser.

Step 4: Update the URLs within the Database

Once you’ve got the Local site’s SSL certificate trusted with macOS, and have verified that the site can be successfully loaded over HTTPS, all that’s left to do is to update the urls within the Local site’s database!

You can use a plugin like Better Search Replace to search for the regular HTTP version of the url and replace it with the HTTPS version of the url.

Another option is to use WPCLI which comes bundled with Local. To do this, all you have to do is:

  1. Right-click on the site in Local and select “Open Site Shell”
  2. Within the terminal window that opens, use the wp search-replace command to update http:// to https://. Using the above site as an example, the command would look something like:
wp search-replace 'http://ssl-madness.local' 'https://ssl-madness.local'
Updating the urls within the Local site’s database using WPCLI.