简体   繁体   English

如何在node.js应用程序中正确安装SSL?

[英]How properly install SSL in a node.js application?

i'm having a problem here, this message is appearing when i test my SSL: 我在这里遇到问题,当我测试我的SSL时出现此消息:

Certificate chain is incomplete.

I already create the http and the https server in my entry point file, and is running in some browsers without problem, but in others appear the message saying the site is not safe because the chain is incomplete. 我已经在我的入口点文件中创建了http和https服务器,并且在某些浏览器中运行没有问题,但在其他浏览器中显示的消息是该站点不安全,因为链不完整。

How can i install properly the SSL to make the chain complete? 如何正确安装SSL以使链完整?

This is how i do: 这是我的方式:

SSL FOLDER
|- credentials.js
|- site.pem
|- site-cert.pem
|- site-ca.pem

In my credentials.js i have: 在我的credentials.js我有:

var fs = require('fs');

var credentials = {
    key: fs.readFileSync(__dirname + '/mysite.pem', 'utf8'),
    cert: fs.readFileSync(__dirname + '/mysite-cert.pem', 'utf8'),
    ca: fs.readFileSync(__dirname +  '/mysite-ca.pem', 'utf8'),
    passphrase: 'secretphrase'
};

module.exports = credentials;

And in my entry point i have: 在我的切入点我有:

var app = require('../app');
var http = require('http');
var https = require('https');
var credentials = require('./ssl/credentials');

http.createServer(app).listen(3000, app.get('ip'), function() {
   console.log('Running on port 3000, in ' + app.get('env') + ' mode.');
});


https.createServer(credentials, app).listen(443, app.get('ip'), function() {
   console.log('Running on port 443, in ' + app.get('env') + ' mode.');
});

Maybe i forget something? 也许我忘了什么?

I'm not getting way the problem with the chain. 我没有解决链条的问题。

You may be required to add intermediate CA certificates that chain up to the root CA cert. 您可能需要添加链接到根CA证书的中间CA证书。 See How to setup EV Certificate with nodejs server 请参见如何使用nodejs服务器设置EV证书

Check your domain with an online SSL Test tool to see if all certificates in the chain are being sent by your server. 使用在线SSL测试工具检查您的域,以查看您的服务器是否正在发送链中的所有证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM