Make sure that it looks for SSL certs only if defined

This commit is contained in:
Jan Oberhauser 2020-03-30 13:29:42 +02:00
parent 60826ba19d
commit 7c5f437e92
2 changed files with 5 additions and 5 deletions

View file

@ -177,13 +177,13 @@ const config = convict({
}, },
ssl_key: { ssl_key: {
format: String, format: String,
default: 'server.key', default: '',
env: 'N8N_SSL_KEY', env: 'N8N_SSL_KEY',
doc: 'SSL Key for HTTPS Protocol' doc: 'SSL Key for HTTPS Protocol'
}, },
ssl_cert: { ssl_cert: {
format: String, format: String,
default: 'server.pem', default: '',
env: 'N8N_SSL_CERT', env: 'N8N_SSL_CERT',
doc: 'SSL Cert for HTTPS Protocol' doc: 'SSL Cert for HTTPS Protocol'
}, },

View file

@ -1268,10 +1268,10 @@ export async function start(): Promise<void> {
let server; let server;
if(app.protocol === 'https'){ if (app.protocol === 'https' && app.sslKey && app.sslCert){
const https = require('https'); const https = require('https');
const privateKey = readFileSync(app.sslKey,'utf8'); const privateKey = readFileSync(app.sslKey, 'utf8');
const cert = readFileSync(app.sslCert,'utf8'); const cert = readFileSync(app.sslCert, 'utf8');
const credentials = { key: privateKey,cert }; const credentials = { key: privateKey,cert };
server = https.createServer(credentials,app.app); server = https.createServer(credentials,app.app);
}else{ }else{