
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
request-ssl-nfd
Advanced tools
$ npm install request-ssl
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.
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.
addFingerprint(name,fingerprint)
: add a fingerprintaddFingerprintDirectory(directory)
: add one or more fingerprints from directoryremoveFingerprint(name)
: remove a named fingerprintremoveAllFingerprints
: remove all fingerprintssetDefaultSecureProtocol(protocol)
: set the default protocol to use for agentOptions
getLastURL
: called to return the very last url pinnedgetFingerprintForURL(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.
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.
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.
FAQs
Pinned SSL version of the Request library
The npm package request-ssl-nfd receives a total of 2 weekly downloads. As such, request-ssl-nfd popularity was classified as not popular.
We found that request-ssl-nfd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.