I'm trying to create HTTPS server with Node.js. I have followed some instructions from web and end up with this code:
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('D:\\NodeJs\\HTTPS\\keys\\pvtkey.pem', 'utf8'),
cert: fs.readFileSync('D:\\NodeJs\\HTTPS\\keys\\cert.pem', 'utf8'),
requestCert: false,
rejectUnauthorized: false
};
https.createServer(options, function (req, res) {
if (req.client.authorized) {
res.writeHead(200, {"Content-Type": "application/json"});
res.end('{"status":"approved"}');
} else {
res.writeHead(401, {"Content-Type": "application/json"});
res.end('{"status":"denied"}');
}
}).listen(443);
console.log('start listing');
When trying access from Chrome, I get the following error:
SSL connection error Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have. Error code: ERR_SSL_PROTOCOL_ERROR
Any advice?