Всем привет. Пытаюсь запустить NodeJS с SSL сертификатом. Фрагмент кода
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
const http = require('http');
const https = require('https');
const fs = require('fs');
// require our custom dependencies
const router = require('./router');
const PORT = process.env.PORT || 8000;
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/../public'));
app.use(router);
//NOT WORK
if (process.env.PROD) {
const options = {
key: fs.readFileSync('path/to/private-key.key'),
cert: fs.readFileSync('path/to/cert.crt'),
// optional
ca: [
fs.readFileSync('path/to/COMODORSADomainValidationSecureServerCA.crt'),
fs.readFileSync('path/to/COMODORSAAddTrustCA.crt')
]
};
https.createServer(options, app).listen(PORT, function () {
console.log('PROD app listening on port', PORT);
});
}
// WORK
else {
http.createServer(app).listen(PORT, function () {
console.log('Example app listening on port', PORT);
});
}
NodeJS запускается, но сам сайт не работает совсем - выдает ERR_EMPTY_RESPONSE если захожу через http
и ERR_CONNECTION_REFUSED - если захожу через https. Если заменить запуск NodeJS на обычный http - сайт работает.
Сайты проверки на соответствие ключа и сертификата типа
https://sslanalyzer.comodoca.com/ не дают результата, т.к. сайт лежит