Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
feat(agent): added opts.strictSSL and opts.localAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 27, 2017
1 parent d1d5109 commit c35015a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ make-fetch-happen augments the `node-fetch` API with additional features availab
* [`opts.cacheManager`](#opts-cache-manager) - Cache target to read/write
* [`opts.cache`](#opts-cache) - `fetch` cache mode. Controls cache *behavior*.
* [`opts.proxy`](#opts-proxy) - Proxy agent
* [`opts.ca, opts.cert, opts.key`](#https-opts)
* [`opts.ca, opts.cert, opts.key, opts.strictSSL`](#https-opts)
* [`opts.localAddress`](#opts-local-address)
* [`opts.maxSockets`](#opts-max-sockets)
* [`opts.retry`](#opts-retry) - Request retry settings
* [`opts.integrity`](#opts-integrity) - [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) metadata.
Expand Down Expand Up @@ -285,12 +286,17 @@ fetch('https://registry.npmjs.org/make-fetch-happen', {
})
```

#### <a name="https-opts"></a> `> opts.ca, opts.cert, opts.key`
#### <a name="https-opts"></a> `> opts.ca, opts.cert, opts.key, opts.strictSSL`

These values are passed in directly to the HTTPS agent and will be used for both
proxied and unproxied outgoing HTTPS requests. They correspond to the same
options the `https` module accepts, which will be themselves passed to
`tls.connect()`.
proxied and unproxied outgoing HTTPS requests. They mostly correspond to the
same options the `https` module accepts, which will be themselves passed to
`tls.connect()`. `opts.strictSSL` corresponds to `rejectUnauthorized`.

#### <a name="opts-local-address"></a> `> opts.localAddress`

Passed directly to `http` and `https` request calls. Determines the local
address to bind to.

#### <a name="opts-max-sockets"></a> `> opts.maxSockets`

Expand Down
13 changes: 10 additions & 3 deletions agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function getAgent (uri, opts) {
pxuri
? `proxy:${pxuri.protocol}//${pxuri.host}:${pxuri.port}`
: '>no-proxy<',
`local-address:${opts.localAddress || '>no-local-address<'}`,
`strict-ssl:${isHttps ? !!opts.strictSSL : '>no-strict-ssl<'}`,
`ca:${(isHttps && opts.ca) || '>no-ca<'}`,
`cert:${(isHttps && opts.cert) || '>no-cert<'}`,
`key:${(isHttps && opts.key) || '>no-key<'}`
Expand Down Expand Up @@ -46,9 +48,12 @@ function getAgent (uri, opts) {
maxSockets: opts.maxSockets || 15,
ca: opts.ca,
cert: opts.cert,
key: opts.key
key: opts.key,
localAddress: opts.localAddress,
rejectUnauthorized: opts.strictSSL
}) : new HttpAgent({
maxSockets: opts.maxSockets || 15
maxSockets: opts.maxSockets || 15,
localAddress: opts.localAddress
})
AGENT_CACHE.set(key, agent)
return agent
Expand Down Expand Up @@ -110,7 +115,9 @@ function getProxy (proxyUrl, opts) {
ca: opts.ca,
cert: opts.cert,
key: opts.key,
maxSockets: opts.maxSockets || 15
localAddress: opts.localAddress,
maxSockets: opts.maxSockets || 15,
rejectUnauthorized: opts.strictSSL
}

if (proxyUrl.protocol === 'http:') {
Expand Down

0 comments on commit c35015a

Please sign in to comment.