Testing service workers on custom local domain with self signed certificate

When playing around with service workers in order to make a site a progressive web app I had to test it on my local dev environment. As service workers need to run on https and I use a self-signed certificate for development. This gave me the following error in the console in Chrome

ServiceWorker registration failed: DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.

The solution is to tell Chrome to accept the certificate even though it is insecure from Chrome’s point of view. Just paste this in your terminal (Mac only) and you should be good to go – just don’t go browsing elsewhere too much:

Leave a Reply

Your email address will not be published. Required fields are marked *