Skip to content

Commit

Permalink
Consider options.rejectUnauthorized when pooling https agents
Browse files Browse the repository at this point in the history
Not doing that was causing `rejectUnauthorized` option to be ignored.
  • Loading branch information
mmalecki authored and indexzero committed Feb 13, 2013
1 parent 20ba1d6 commit 0150d9f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ Request.prototype.getAgent = function () {
}
}
if (this.ca) options.ca = this.ca
if (typeof this.rejectUnauthorized !== 'undefined')
options.rejectUnauthorized = this.rejectUnauthorized;

var poolKey = ''

Expand All @@ -497,10 +499,17 @@ Request.prototype.getAgent = function () {
// ca option is only relevant if proxy or destination are https
var proxy = this.proxy
if (typeof proxy === 'string') proxy = url.parse(proxy)
var caRelevant = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:'
if (options.ca && caRelevant) {
if (poolKey) poolKey += ':'
poolKey += options.ca
var isHttps = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:'
if (isHttps) {
if (options.ca) {
if (poolKey) poolKey += ':'
poolKey += options.ca
}

if (typeof options.rejectUnauthorized !== 'undefined') {
if (poolKey) poolKey += ':'
poolKey += options.rejectUnauthorized
}
}

if (!poolKey && Agent === this.httpModule.Agent && this.httpModule.globalAgent) {
Expand Down

0 comments on commit 0150d9f

Please sign in to comment.