Search code examples
polymerpolymer-1.0http2

Why does SimpleHTTP2Server fail to load service worker on localhost


When I try to run the Polymer Shop locally, both the bundled and unbundled builds, using the SimpleHTTP2Server , on my local host using port 5000, the request for service-worker.js fails:

An SSL certificate error occurred when fetching the script.
https://localhost:5000/service-worker.js Failed to load resource: net::ERR_INSECURE_RESPONSE
(index):1 Uncaught (in promise) DOMException: Failed to register a     ServiceWorker: An SSL certificate error occurred when fetching the script.

Is there an easy way to get this to work? I tried a number of start up flags, like:

chrome.exe --ignore-certificate-errors --incognito
--unsafely-treat-insecure-origin-as-secure --allow-insecure-localhost

but that didn't help, I still get:

(index):1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.

Solution

  • Following alesc's suggestion, I found instructions here:

    These are instructions for Chrome 55 on Windows 10. It seems these steps may change frequently.

    1. On the page with the untrusted certificate (https:// is crossed out in red), click the lock so a popup opens up.
    2. Click the Details link under the information section at the top.
    3. Click on the View Certificate button.
    4. Click on the Details tab
    5. Click on the Copy to File
    6. Click Next
    7. Export as PKCS #7
    8. Open up Chrome Settings > Show advanced settings > HTTPS/SSL > Manage Certificates
    9. Import the certificate created in step 7 to both the Intermediate Certificate Authorities tab as well as the Trusted Authorities Tab.
    10. Restart Chrome and open your localhost site.