From 658b0952541925543b74855bdab064cda8125a5c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 3 Feb 2017 11:55:17 -0700 Subject: [PATCH] use any available *localhost*.daplie.me certificate --- bin/serve-https.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/serve-https.js b/bin/serve-https.js index 6fde3bf..b0cc66f 100755 --- a/bin/serve-https.js +++ b/bin/serve-https.js @@ -141,13 +141,17 @@ function createServer(port, _delete_me_, content, opts) { 'localhost.daplie.me': null }; opts.httpsOptions.SNICallback = function (sni, cb ) { + var tlsOptions; console.log('[https] sni', sni); // Static Certs - if ('localhost.daplie.me' === sni) { + if (/.*localhost.*\.daplie\.me/.test(sni.toLowerCase())) { // TODO implement if (!secureContexts[sni]) { - secureContexts[sni] = tls.createSecureContext(require('localhost.daplie.me-certificates').merge({})); + tlsOptions = require('localhost.daplie.me-certificates').mergeTlsOptions(sni, {}); + } + if (tlsOptions) { + secureContexts[sni] = tls.createSecureContext(tlsOptions); } cb(null, secureContexts[sni]); return;