I'm getting error while trying to access HTTPS server I created with NodeJS.
What do I do :
1.First of all : generate a self-signed certificate :
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
2.Create simple NodeJs Https server -
var https = require('https');
var fs = require('fs');
var server_port = 8080;
var httpsOptions = {
key: fs.readFileSync('\key.pem'),
cert: fs.readFileSync('\cert.pem')
};
var app = function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}
https.createServer(httpsOptions, app).listen(server_port);
run the server : node main.js (the file name) The server is running but when I try access https://localhost:8080
Connect to the server. The result is: