From bf0cd2af723a60dcb2a5332cd94cb2f1cbc81828 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Sun, 1 Jan 2017 17:36:42 -0800 Subject: [PATCH] Support for intermediate certificates in SSL --- lib/server.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/server.coffee b/lib/server.coffee index b36e415..0b75d77 100644 --- a/lib/server.coffee +++ b/lib/server.coffee @@ -68,10 +68,17 @@ if useHttps fs = require 'fs' httpsKey = path.resolve(config.get('CONFIG_DIR'), "#{service}.key") httpsCert = path.resolve(config.get('CONFIG_DIR'), "#{service}.crt") + httpsCa = path.resolve(config.get('CONFIG_DIR'), "#{service}.ca-bundle") options = { key: fs.readFileSync(httpsKey), cert: fs.readFileSync(httpsCert) } + + try + # Use intermediate certificates if available + options.ca = fs.readFileSync(httpsCa).toString() + .match(/\-+BEGIN CERTIFICATE\-+[0-9a-zA-Z\+\-\/\=\s]+?\-+END CERTIFICATE\-+/g) + server = require('https').createServer(options, listener) else server = require('http').createServer(listener)