0





30

Advertisement

I'm trying to make a start at Service Workers and read you require to have an ssl cert.

I've Got an AngularJS 1.x application and a Node Express back end, and I run both independently so I I use grunt serve to run the front end on port 8443 and I use node app.js to run express which is on 7443.

note: I'm doing this on macOS

I used the guide on how to set up https on a project that uses Grunt: here

openssl genrsa -out livereload.key 1024

openssl req -new -key livereload.key -out livereload.csr

openssl x509 -req -in livereload.csr -signkey livereload.key -out livereload.crt

Gruntfile.js

options: {
    protocol: 'https', // or 'http2'
    port: 8443,
    hostname: '0.0.0.0',
    key: grunt.file.read('livereload.key'),
    cert: grunt.file.read('livereload.crt')
},

node app.js

var privateKey  = fs.readFileSync('../livereload.key', 'utf8');
var certificate = fs.readFileSync('../livereload.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};

httpsServer.listen(7443, config.ip, function () {
  console.log('Express server listening on %d, in %s mode', 7443, app.get('env'));
});

Both start with no errors, the front end does complain the connection is not private. When my front end tried to hit an endpoint on the express server I receive the following;

OPTIONS https://localhost:7443/api/census/general net::ERR_INSECURE_RESPONSE

Could someone please assist on this problem of mine.

Question author Bettercalldough | Source

Advertisement


0


You have created a self-signed certificate, which is fine for development and testing but is considered unsafe for general use. Unlike SSL certificates purchased from reputable third-parties, self-signed certificates are untrusted by default.

You will need to tell your OS to explicitly trust the certificate. I'm unfamiliar with Mac OS but this question was previously answered on SuperUser.

Answer author Djones