javascript - 您的连接不是 Node js 中的私有(private)错误

标签 javascript node.js ssl

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

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());
 });

编辑:
一旦我点击高级并继续不安全的服务器。然后它正在浏览器中显示绿色填充。

最佳答案

您的 Node https 配置未发送中间证书。使用 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 设置。

关于javascript - 您的连接不是 Node js 中的私有(private)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44139467/

相关文章:

javascript - 删除在 CSS 文件中设置的 CSS 属性(不是内联 CSS)[jQuery]

php - 带有 SSL 套接字的 CodeIgniter 和 Gmail SMTP 超时

node.js - AWS Lambda 图像损坏

javascript - ExpressJS 和痛饮 : Changing template variables based on route?

Python 请求 ssl [Errno 1] _ssl.c :1428: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

ssl - 通配符证书支持嵌套子域吗?

javascript - 三元条件下的多个 OR 运算符,

javascript - 对象数组: reference to existing objects or new instances

javascript - AngularJS中表达式ng-keypress事件的意外结束

javascript - Nodejs中设置Prototype类的成员变量