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

cert-expiry-check

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cert-expiry-check

A module to check the expiry of HTTPS certificates

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cert-expiry-check

CircleCI npm version

A module to check the expiry of SSL/TLS certs.

Usage

In it's most basic form, using the default configuration:

const CertExpiryCheck = require('cert-expiry-check');
const checker = new CertExpiryCheck();
checker.checkHosts([{
  hostname: 'www.google.com'
}]).then((results) => {
  console.log(results);
}).catch((e) => {
  console.error(e); // bubbles up HTTP errors and invalid cert chains
});

Gives the following result:

[{
  "host":{
    "hostname":"www.google.com",
    "port":443,
    "alertWindowDays":30,
    "headers":{
      "User-Agent":"SSL Certificate Expiry Checker 0.1.0"
    },
    "method":"GET"
  },
  "details":{
    "subject":{
      "org":"Google Inc",
      "commonName":"www.google.com",
      "altName":"DNS:www.google.com"
    },
    "issuer":{
      "org":"Google Inc",
      "commonName":"Google Internet Authoritym G2"
    }
  },
  "validFrom":"2016-05-18T10:59:02.000Z",
  "validTo":"2016-08-10T10:46:00.000Z",
  "expiry":{
    "days":72,
    "milliseconds":6198331472,
    "isExpired":false,
    "isInAlertWindow":false
  }
}]

There are two types of configurations that can be performed, first the 'global' defaults used for all checked domains:

const checker = new CertExpiryCheck({
  timeout: 5000, // timeout used for HTTPS connections
  defaultPort: 443, // port used for all HTTPS connections
  defaultAlertWindowDays: 30, // default alert window to use for near expiry certs
  userAgent: 'SSL Certificate Expiry Checker 0.1.0' // default user agent to send with requests
});

Secondly, the per host configurations that override the defaults (above) for each host to check:

checker.checkHosts([{
  hostname: 'www.google.com',
  port: 443,
  alertWindowDays: 30,
  userAgent: 'SSL Certificate Expiry Checker 0.1.0'
}]).then((results) => {
  console.log(results);
})

Note: There is currently no support for self-signed certs, as this was outside of the core use-case. Happy to accept pull requests for support however.

Development

git clone https://github.com/Joe8Bit/cert-expiry-check
cd cert-expiry-check
npm install -g ava nyc eslint babel-eslint && npm install
npm test

Contributing

All contributors agree to abide by the CODE_OF_CONDUCT.md

License

MIT

FAQs

Package last updated on 31 May 2016

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