Ssl – Node.js SSL: Invalid Certificate

node.jsopensslsslssl-certificate

I am trying to apply SSL layer to a node.js server.

Following are the steps I have done

  1. Created all the ssl resources using this blog
  2. Followed the instructions given in here to start my node.js server without entering the pem passphrase
  3. My node.js code is

    var app = express();

    var options = {
    key: fs.readFileSync('./sslCA/server.key'),
    cert: fs.readFileSync('./sslCA/server.crt'),
    ca: fs.readFileSync('./sslCA/ca.crt'),
    requestCert: true,
    rejectUnauthorized: false
    };

    app.set('port', process.env.PORT || 3000);
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.set('view options', { layout: false});
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());

    app.use(express.static(path.join(__dirname, 'public')));

    https.createServer(options,app).listen(app.get('port'), function(){
    console.log('Express server listening on port ' + app.get('port'));
    });

When I point my IE10 browser to localhost I get the error

There is a problem with this website's security certificate.

The security certificate presented by this website is not secure.

Security certificate problems may indicate an attempt to fool you or intercept any data you send to the server.  

We recommend that you close this webpage and do not continue to this website.  

When I point my chrome browser to localhost I get the error

Invalid Server Certificate
You attempted to reach localhost, but the server presented an invalid certificate

Please help me understand what I have done wrong.

Best Answer

i resolved the error.

Turns out that after removing the passphrase from my server.key I must regenerate the server certificate.