Skip to content

gakada/agent-options

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

As stated in the documentation for https.request:

The following additional options from tls.connect() are also accepted when using a custom Agent: ca, cert, ciphers, clientCertEngine, key, passphrase, pfx, rejectUnauthorized, secureProtocol, servername.

This module allows to modify other options, as well as to disable them. For example, SNI can be disabled by setting servername to null (or undefined).

Install

$ npm i agent-options

Usage

Examples

Performing https.request without SNI:

const https = require('https')
const makeAgent = require('agent-options')

const options = {
  host: 'example.com',
  port: 443,
  path: '/',
  agent: makeAgent({ servername: null })
}

const req = https.request(options, res => {
  res.on('data', data => {
    // ...
  })
  res.on('end', () => {
    // ...
  })
})

req.on('error', err => {
  // ...
})

req.end()

Same using got:

const got = require('got')
const makeAgent = require('agent-options')

got('example.com', { agent: makeAgent({ servername: null }) }).then(res => {
  // ...
}).catch(err => {
  // ...
})

Issues

  • Support agents other than https.Agent?

About

Custom tls.connect options for https.Agent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published