From 501fb5a46b346e53494f91ccb1ea2382ca11b7b0 Mon Sep 17 00:00:00 2001 From: Tobias Muellerleile Date: Tue, 6 May 2014 07:36:18 +0200 Subject: [PATCH 1/2] Accept buffers for cert/key in createServer --- lib/server.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index 2e80ef5..2ef676a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -258,10 +258,12 @@ function Server(options) { if (options.certificate || options.key) { if (!(options.certificate && options.key) || - typeof (options.certificate) !== 'string' || - typeof (options.key) !== 'string') { - throw new TypeError('options.certificate and options.key (string) ' + - 'are both required for TLS'); + (typeof (options.certificate) !== 'string' && + !Buffer.isBuffer(options.key)) || + (typeof (options.key) !== 'string' && + !Buffer.isBuffer(options.key))) { + throw new TypeError('options.certificate and options.key ' + + '(string or buffer) are both required for TLS'); } } } else { From e3d8ba2f37a5c8ddb3022de64163d069d5aea00a Mon Sep 17 00:00:00 2001 From: Tobias Muellerleile Date: Tue, 6 May 2014 14:33:43 +0200 Subject: [PATCH 2/2] Fixup for 501fb5a46b346e53494f91ccb1ea2382ca11b7b0 --- lib/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index 2ef676a..89da85e 100644 --- a/lib/server.js +++ b/lib/server.js @@ -259,7 +259,7 @@ function Server(options) { if (options.certificate || options.key) { if (!(options.certificate && options.key) || (typeof (options.certificate) !== 'string' && - !Buffer.isBuffer(options.key)) || + !Buffer.isBuffer(options.certificate)) || (typeof (options.key) !== 'string' && !Buffer.isBuffer(options.key))) { throw new TypeError('options.certificate and options.key ' +