您的连接不是Node js中的私有错误

时间:2017-05-23 15:44:47

标签: javascript node.js ssl

我创建了Node js服务器。我的ubuntu系统在端口443中运行两个服务器apache,在端口442中运行节点js服务器。使用SSL证书运行良好的Apache服务器但是节点js显示SSL错误。
enter image description here 您的连接不是私密的

server.js:

var express = require('express');
var https = require('https');
var http = require('http');
var fs = require('fs');
var inbox=require('./functions.js');
var app = express();

// This line is from the Node.js HTTPS documentation.
var options = {
 key: fs.readFileSync('/etc/ssl/biz.key'),
 cert: fs.readFileSync('/etc/ssl/biz.crt')
};

 // Create a service (the app object is just a callback).

 app.use(function (req, res, next) {

// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');

// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');

// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');

// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);

// Pass to next layer of middleware
 next();
});


 // Create an HTTP service.
 http.createServer(app).listen(81);
 // Create an HTTPS service identical to the HTTP service.
 https.createServer(options, app).listen(442,function () {
   console.log('Server Time'+new Date().Now());
 });

修改
一旦我点击高级并进入不安全的服务器。然后它在浏览器中显示绿色填充。

1 个答案:

答案 0 :(得分:1)

您的节点https config未发送中间证书。使用ca选项发送这些内容,以便客户端能够形成完整的链。

var options = {
 key: fs.readFileSync('/etc/ssl/biz.key'),
 cert: fs.readFileSync('/etc/ssl/biz.crt'),
 ca: <insert your ca bundle here>
};

如果从Apache(通过端口443)提供的站点也在移动浏览器中显示此警告,则必须在Apache中执行类似的操作。您可以使用SSL Labs来测试您网站的证书和其他TLS设置。