vineet
vineet

Reputation: 14246

https ssl/tls not working at localhost in Nodejs

https module not working at my localhost. I have go through this blog.mgechev.com tutorial. My node v5.10.1.

Here code:

//index.js
var fs = require('fs'),
https = require('https'),
express = require('express'),
app = express();

https.createServer({
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
}, app).listen(55555);

app.get('/', function (req, res) {
  res.header('Content-type', 'text/html');
  return res.end('<h1>Hello, Secure World!</h1>');
});

node index.js

Output:

enter image description here

Upvotes: 2

Views: 1418

Answers (1)

vineet
vineet

Reputation: 14246

It is silly mistake. I just hit url with preceding https and it working fine.

That is:-

https://localhost:55555

Upvotes: 2

Related Questions