create-servers
Advanced tools
Comparing version 2.0.1 to 2.1.0
46
index.js
@@ -15,3 +15,4 @@ 'use strict'; | ||
connected = require('connected'), | ||
errs = require('errs'); | ||
errs = require('errs'), | ||
assign = require('object-assign'); | ||
@@ -126,32 +127,30 @@ var CIPHERS = [ | ||
var port = +options.https.port || 443, | ||
ssl = options.https, | ||
var ssl = options.https, | ||
port = +ssl.port || 443, | ||
ciphers = ssl.ciphers || CIPHERS, | ||
ca = ssl.ca, | ||
server, | ||
args, | ||
ip; | ||
args; | ||
ssl.ciphers = ssl.ciphers || CIPHERS; | ||
// | ||
// Remark: If an array is passed in lets join it like we do the defaults | ||
// | ||
if (Array.isArray(ssl.ciphers)) { | ||
ssl.ciphers = ssl.ciphers.join(':'); | ||
if (Array.isArray(ciphers)) { | ||
ciphers = ciphers.join(':'); | ||
} | ||
if (ssl.ca && !Array.isArray(ssl.ca)) { | ||
ssl.ca = [ssl.ca]; | ||
if (ca && !Array.isArray(ca)) { | ||
ca = [ca]; | ||
} | ||
log('https | listening on %d', port); | ||
server = https.createServer({ | ||
var finalHttpsOptions = assign({}, ssl, { | ||
// | ||
// Load default SSL key, cert and ca(s). | ||
// | ||
key: fs.readFileSync(path.resolve(ssl.root, ssl.key)), | ||
key: fs.readFileSync(path.resolve(ssl.root, ssl.key)), | ||
cert: fs.readFileSync(path.resolve(ssl.root, ssl.cert)), | ||
ca: ssl.ca && ssl.ca.map( | ||
function (file) { | ||
return fs.readFileSync(path.resolve(ssl.root, file)); | ||
} | ||
ca: ca && ca.map( | ||
function (file) { | ||
return fs.readFileSync(path.resolve(ssl.root, file)); | ||
} | ||
), | ||
@@ -162,9 +161,5 @@ // | ||
// | ||
ciphers: ssl.ciphers, | ||
ciphers: ciphers, | ||
honorCipherOrder: !!ssl.honorCipherOrder, | ||
// | ||
// Optionally support SNI-based SSL. | ||
// | ||
SNICallback: ssl.SNICallback, | ||
// | ||
// Protect against the POODLE attack by disabling SSLv3 | ||
@@ -175,4 +170,7 @@ // @see http://googleonlinesecurity.blogspot.nl/2014/10/this-poodle-bites-exploiting-ssl-30.html | ||
secureOptions: require('constants').SSL_OP_NO_SSLv3 | ||
}, ssl.handler || handler); | ||
}); | ||
log('https | listening on %d', port); | ||
server = https.createServer(finalHttpsOptions, ssl.handler || handler); | ||
args = [server, port]; | ||
@@ -179,0 +177,0 @@ if (options.https.host) { |
{ | ||
"name": "create-servers", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Create an http AND/OR an https server and call the same request handler.", | ||
@@ -26,7 +26,9 @@ "main": "index.js", | ||
"connected": "~0.0.2", | ||
"errs": "~0.3.0" | ||
"errs": "~0.3.0", | ||
"object-assign": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"sinon": "^1.17.4", | ||
"tape": "~2.14.0" | ||
} | ||
} |
@@ -10,3 +10,5 @@ /* | ||
http = require('http'), | ||
https = require('https'), | ||
test = require('tape'), | ||
sinon = require('sinon'), | ||
createServers = require('../'); | ||
@@ -177,1 +179,22 @@ | ||
}); | ||
test('supports requestCert https option', function (t) { | ||
t.plan(2); | ||
var spy = sinon.spy(https, 'createServer'); | ||
createServers({ | ||
log: console.log, | ||
https: { | ||
port: 3456, | ||
root: path.join(__dirname, 'fixtures'), | ||
cert: 'agent2-cert.pem', | ||
key: 'agent2-key.pem', | ||
requestCert: true | ||
}, | ||
handler: fend | ||
}, function (err, servers) { | ||
t.error(err); | ||
t.equals(spy.lastCall.args[0].requestCert, true, 'should preserve the requestCert option'); | ||
servers.https.close(); | ||
spy.restore(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16545
346
3
2
4
+ Addedobject-assign@^4.1.0
+ Addedobject-assign@4.1.1(transitive)