【问题标题】:your connection is not private error in Node js您的连接不是 Node js 中的私人错误
【发布时间】:2017-05-23 15:44:47
【问题描述】:

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

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

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

【问题讨论】:

  • 它抱怨权威。我们应该假设它不是自签名证书吗?
  • 你的biz.key/etc/ssl/biz.crt 是从哪里得到的……它们是自签名的吗?
  • 您应该将选项中的密钥和证书链接到与 apache 使用的资源相同的资源
  • @ÁlvaroGonzález 不,它们是原创的。不是自称从 GoDaddy 购买的。它在 apache 上运行良好。
  • @Pogrindis 不,他们不是自分配的。

标签: javascript node.js ssl


【解决方案1】:

您的节点 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 设置。

【讨论】:

    猜你喜欢
    • 2016-09-02
    • 2015-04-01
    • 2020-07-21
    • 1970-01-01
    • 2017-12-09
    • 2018-11-27
    • 2021-12-21
    • 2022-06-10
    • 1970-01-01
    相关资源
    最近更新 更多