简体   繁体   中英

How properly install SSL in a node.js application?

i'm having a problem here, this message is appearing when i test my 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.

How can i install properly the SSL to make the chain complete?

This is how i do:

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

In my credentials.js i have:

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. See How to setup EV Certificate with nodejs server

Check your domain with an online SSL Test tool to see if all certificates in the chain are being sent by your server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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