Q:

Service worker over http: An SSL certificate error occurred when fetching the script

I'm using a service worker with https not https for my angular 4 project.  But I get this error :
Service Worker registration failed:  DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script. 
Here is my service-worker.js
module.exports = {
    navigateFallback: '/index.html',
    stripPrefix: 'dist',
    root: 'dist/',
    staticFileGlobs: [
        'dist/index.html',
        'dist/**.js',
        'dist/**.css',
        'dist/assets/image/**.*', 
        'dist/assets/image/client-home-carousel/**.*', 
    ]
};

An in angular-cli.json:
"assets": [
            "assets",
            "favicon.ico",
            "service-worker.js"
        ],

A:

Service Workers can only be used over an HTTPS connection.  Are you using that or not?  Also, the HTTPS certificate has to be valid. 
As a sidenote, the code you're showing is not your service-worker.js.  That code is some parameters and options to some SW library that then generates your service-worker.js based on those options.  Most likely your actual service-worker.js is located in the dist directory and is updated as a part of your build process.