Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

https-agent

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

https-agent

Proxy aware HTTPS agent

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
increased by65.02%
Maintainers
1
Weekly downloads
 
Created
Source

https-agent

Build Status

HTTPS agent for Node with transparent proxy support

Creates a HTTPS agent that automatically handles proxy tunnelling using the https_proxy environment variable. You can then plug the agent into your HTTP client of choice and make requests using SSL client authentication.

Installation

npm install https-agent

Usage

var httpsAgent = require('https-agent');
var fs = require('fs');

var agent = httpsAgent({
  pfx: fs.readFileSync('/path/to/client.p12'),
  passphrase: 'client'
});

All of the standard TLS options are supported when creating an agent. Use the pfx and passphrase options for a certificate in PKCS12 format or the cert and key options for separate certificate and key files.

Examples

Usage with https.get

var httpsAgent = require('https-agent');
var fs = require('fs');
var https = require('https');

var agent = httpsAgent({
  pfx: fs.readFileSync('/path/to/client.p12'),
  passphrase: 'client'
});

var options = {
  protocol: 'https:',
  hostname: 'www.example.com',
  port: 443,
  agent: agent
}

https.get(options, function (res) {
  res.on('data', function (data) {
    console.log(data.toString());
  });
});

Usage with request

var httpsAgent = require('https-agent');
var fs = require('fs');
var request = require('request');

var agent = httpsAgent({
  pfx: fs.readFileSync('/path/to/client.p12'),
  passphrase: 'client'
});

request('https://www.example.com', {agent: agent, proxy: false}, function (err, res, body) {
  console.log(body);
});

Usage with node-rest-client

var httpsAgent = require('https-agent');
var fs = require('fs');
var Client = require('node-rest-client').Client;

var agent = httpsAgent({
  pfx: fs.readFileSync('/path/to/client.p12'),
  passphrase: 'client'
});

var client = new Client({
  connection: {
    agent: agent
  }
});

client.get('https://www.example.com', function (body, res) {
  console.log(body);
});

Keywords

FAQs

Package last updated on 11 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc