Skip to content

Commit e35545d

Browse files
committed
[fix] Allow all keys, certs, ca's to be specified as array
1 parent 07b2245 commit e35545d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ module.exports = function createServers(options, listening) {
190190
* certificate material read from that file path.
191191
*/
192192
function normalizeCertFile(root, file) {
193+
if (Array.isArray(file)) return file.map(function map(item) {
194+
return normalizeCertFile(root, item)
195+
});
196+
193197
//
194198
// Assumption that this is a Buffer, a PEM file, or something broken
195199
//

test/create-servers-test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,26 @@ test('supports cert contents instead of cert paths', function (t) {
254254
});
255255
});
256256

257+
test('supports cert array instead of strings', function (t) {
258+
t.plan(3);
259+
var root = path.join(__dirname, 'fixtures');
260+
createServers({
261+
log: console.log,
262+
https: {
263+
port: 3456,
264+
root: root,
265+
cert: [fs.readFileSync(path.resolve(root, 'agent2-cert.pem'))],
266+
key: fs.readFileSync(path.resolve(root, 'agent2-key.pem'))
267+
},
268+
handler: fend
269+
}, function (err, servers) {
270+
t.error(err);
271+
t.equals(typeof servers, 'object');
272+
t.equals(typeof servers.https, 'object');
273+
servers.https.close();
274+
});
275+
});
276+
257277
test('supports requestCert https option', function (t) {
258278
t.plan(2);
259279
var spy = sinon.spy(https, 'createServer');

0 commit comments

Comments
 (0)