npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

request-ssl

v0.0.14

Published

Pinned SSL version of the Request library

Downloads

31

Readme

Request SSL Build Status npm version

Quick Start

$ npm install request-ssl

Overview

Pinned SSL version of the Node.JS Request library by Mikeal Rogers.

This can be used in place of the request library to support SSL Certificate Pinning.

For SSL, HTTP clients will establish a secure connection with a remote server when HTTPS is the protocol. The client and server will exchange certificates as a way to establish secure communication. By default, the client blindly trusts that the server presenting the SSL Certificate is who they say they are. However, how does the client trust that the server presenting the SSL certificate is you think that they are?

Using SSL pinning in the client, the client will verify that the SSL Certificate being presented by the server matches the SHA1 fingerprint of the X.509 Certificate's public key. If the SHA1 matches the fingerprint for the domain that you expect, then you can proceed with the communication.

Usage

First, you should get the SHA1 fingerprint from your server. Make sure you get the final URL if the server performs 301/302 HTTP redirects.

You can use the openssl tool (if you have it installed on your system):

openssl x509  -noout -fingerprint -sha1 -in <(openssl x509 -in <(openssl s_client -connect www.google.com:443 -prexit 2>/dev/null))

The output should be something like:

SHA1 Fingerprint=AD:B8:73:14:D5:26:84:AD:CC:6D:DE:34:09:08:DD:A4:96:F9:B2:90

Optionally, you can also use your browser to get the fingerprint. In your browser, typically, there is a lock in the URL bar for a HTTPS URL. If you click on the lock you usually can get details about the certificate and can find the SHA1 fingerprint string.

The other easy way is to use a fingerprint site.

You should use this fingerprint such as:

var request = require('request-ssl');
request.addFingerprint('www.google.com', 'AD:B8:73:14:D5:26:84:AD:CC:6D:DE:34:09:08:DD:A4:96:F9:B2:90');
request('https://www.google.com',function(err,resp,body){
    // if you get here, it should be secure
});

You can also load fingerprints by domain from a file directory.

var request = require('request-ssl');
request.addFingerprintDirectory('./mydirectory');
request('https://www.google.com',function(err,resp,body){
    // if you get here, it should be secure
});

The filename should be the name of the domain (without protocol and with no file extension). The contents of the file should be the fingerprint.

You can have multiple fingerprints in the directory, in which case all fingerprints will be added.

API

  • addFingerprint(name,fingerprint): add a fingerprint
  • addFingerprintDirectory(directory): add one or more fingerprints from directory
  • removeFingerprint(name): remove a named fingerprint
  • removeAllFingerprints: remove all fingerprints
  • setDefaultSecureProtocol(protocol): set the default protocol to use for agentOptions
  • getLastURL: called to return the very last url pinned
  • getFingerprintForURL(url,callback): get a fingerprint for a url. (only available on machines with openssl binary such as OSX and Linux. For Win32, you have to install openssl to use this)

In addition to the APIs above, all APIs that are on the request library are also available (such as get, post, etc). This library should be a drop-in replacement for the request library.

Debugging

You can turn on debug logging to help aid debugging.

Run your application and set the environment variable DEBUG to request-ssl such as:

DEBUG=request-ssl node app

This should print a lot of debug logging to the console which should provide more information about each request.

Licensing

This library was written by Jeff Haynie / @jhaynie. Copyright(c) 2015 by Jeff Haynie. All Rights Reserved. Licensed under the Apache Public License, version 2. See the LICENSE file for more details.