nodejs https server certificate error

时间:2016-02-12 21:26:38

标签: node.js

I am unable to use HTTPS and send the index.html to the client.

Nodejs code:

select id
from clients
order by length(id) desc, id desc
limit 1;

I get this error, should I be calling options in the https.get function?

var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var fs = require('fs');
var https = require('https');
var options = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem'),
  rejectUnauthorized: false
};
https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(443);
https.get('/', function(request, response){
  response.sendFile('/home/ubuntu/index.html');
});

1 个答案:

答案 0 :(得分:0)

你试过process.env.NODE_TLS_REJECT_UNAUTHORIZED =“0”; - Maverick976