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

ssl-checker

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssl-checker - npm Package Compare versions

Comparing version 2.0.9 to 2.0.10

79

lib/cjs/index.js

@@ -69,3 +69,4 @@ 'use strict';

port: 443,
rejectUnauthorized: false
rejectUnauthorized: false,
validateSubjectAltName: false
};

@@ -81,28 +82,54 @@ var sslChecker = function (host, options) {

try {
var req_1 = https__namespace.request(__assign({ host: host }, options), function (res) {
var _a = res.socket.getPeerCertificate(), valid_from = _a.valid_from, valid_to = _a.valid_to, subjectaltname = _a.subjectaltname;
res.socket.destroy();
if (!valid_from || !valid_to || !subjectaltname) {
reject(new Error("No certificate"));
return;
}
var validTo = new Date(valid_to);
var validFor = subjectaltname
.replace(/DNS:|IP Address:/g, "")
.split(", ");
resolve({
daysRemaining: getDaysRemaining(new Date(), validTo),
valid: res.socket
.authorized || false,
validFrom: new Date(valid_from).toISOString(),
validTo: validTo.toISOString(),
validFor: validFor
if (options.validateSubjectAltName) {
var req_1 = https__namespace.request(__assign({ host: host }, options), function (res) {
var _a = res.socket.getPeerCertificate(), valid_from = _a.valid_from, valid_to = _a.valid_to, subjectaltname = _a.subjectaltname;
res.socket.destroy();
if (!valid_from || !valid_to || !subjectaltname) {
reject(new Error("No certificate"));
return;
}
var validTo = new Date(valid_to);
var validFor = subjectaltname
.replace(/DNS:|IP Address:/g, "")
.split(", ");
resolve({
daysRemaining: getDaysRemaining(new Date(), validTo),
valid: res.socket
.authorized || false,
validFrom: new Date(valid_from).toISOString(),
validTo: validTo.toISOString(),
validFor: validFor
});
});
});
req_1.on("error", reject);
req_1.on("timeout", function () {
req_1.destroy();
reject(new Error("Timed Out"));
});
req_1.end();
req_1.on("error", reject);
req_1.on("timeout", function () {
req_1.destroy();
reject(new Error("Timed Out"));
});
req_1.end();
}
else {
var req_2 = https__namespace.request(__assign({ host: host }, options), function (res) {
var _a = res.socket.getPeerCertificate(), valid_from = _a.valid_from, valid_to = _a.valid_to;
res.socket.destroy();
if (!valid_from || !valid_to) {
reject(new Error("No certificate"));
return;
}
var validTo = new Date(valid_to);
resolve({
daysRemaining: getDaysRemaining(new Date(), validTo),
valid: res.socket
.authorized || false,
validFrom: new Date(valid_from).toISOString(),
validTo: validTo.toISOString()
});
});
req_2.on("error", reject);
req_2.on("timeout", function () {
req_2.destroy();
reject(new Error("Timed Out"));
});
req_2.end();
}
}

@@ -109,0 +136,0 @@ catch (e) {

@@ -48,3 +48,4 @@ import * as https from 'https';

port: 443,
rejectUnauthorized: false
rejectUnauthorized: false,
validateSubjectAltName: false
};

@@ -60,28 +61,54 @@ var sslChecker = function (host, options) {

try {
var req_1 = https.request(__assign({ host: host }, options), function (res) {
var _a = res.socket.getPeerCertificate(), valid_from = _a.valid_from, valid_to = _a.valid_to, subjectaltname = _a.subjectaltname;
res.socket.destroy();
if (!valid_from || !valid_to || !subjectaltname) {
reject(new Error("No certificate"));
return;
}
var validTo = new Date(valid_to);
var validFor = subjectaltname
.replace(/DNS:|IP Address:/g, "")
.split(", ");
resolve({
daysRemaining: getDaysRemaining(new Date(), validTo),
valid: res.socket
.authorized || false,
validFrom: new Date(valid_from).toISOString(),
validTo: validTo.toISOString(),
validFor: validFor
if (options.validateSubjectAltName) {
var req_1 = https.request(__assign({ host: host }, options), function (res) {
var _a = res.socket.getPeerCertificate(), valid_from = _a.valid_from, valid_to = _a.valid_to, subjectaltname = _a.subjectaltname;
res.socket.destroy();
if (!valid_from || !valid_to || !subjectaltname) {
reject(new Error("No certificate"));
return;
}
var validTo = new Date(valid_to);
var validFor = subjectaltname
.replace(/DNS:|IP Address:/g, "")
.split(", ");
resolve({
daysRemaining: getDaysRemaining(new Date(), validTo),
valid: res.socket
.authorized || false,
validFrom: new Date(valid_from).toISOString(),
validTo: validTo.toISOString(),
validFor: validFor
});
});
});
req_1.on("error", reject);
req_1.on("timeout", function () {
req_1.destroy();
reject(new Error("Timed Out"));
});
req_1.end();
req_1.on("error", reject);
req_1.on("timeout", function () {
req_1.destroy();
reject(new Error("Timed Out"));
});
req_1.end();
}
else {
var req_2 = https.request(__assign({ host: host }, options), function (res) {
var _a = res.socket.getPeerCertificate(), valid_from = _a.valid_from, valid_to = _a.valid_to;
res.socket.destroy();
if (!valid_from || !valid_to) {
reject(new Error("No certificate"));
return;
}
var validTo = new Date(valid_to);
resolve({
daysRemaining: getDaysRemaining(new Date(), validTo),
valid: res.socket
.authorized || false,
validFrom: new Date(valid_from).toISOString(),
validTo: validTo.toISOString()
});
});
req_2.on("error", reject);
req_2.on("timeout", function () {
req_2.destroy();
reject(new Error("Timed Out"));
});
req_2.end();
}
}

@@ -88,0 +115,0 @@ catch (e) {

@@ -0,1 +1,2 @@

/// <reference types="node" />
import * as https from "https";

@@ -7,5 +8,8 @@ interface IResolvedValues {

daysRemaining: number;
validFor: string[];
validFor?: string[];
}
declare const sslChecker: (host: string, options?: Partial<https.RequestOptions>) => Promise<IResolvedValues>;
type Options = https.RequestOptions & {
validateSubjectAltName?: boolean;
};
declare const sslChecker: (host: string, options?: Partial<Options>) => Promise<IResolvedValues>;
export default sslChecker;
{
"name": "ssl-checker",
"version": "2.0.9",
"version": "2.0.10",
"description": "ssl-checker",

@@ -42,3 +42,3 @@ "main": "./lib/cjs/index.js",

"typescript": "^4.9.5",
"vitest": "^0.28.4"
"vitest": "^1.3.1"
},

@@ -45,0 +45,0 @@ "files": [

@@ -32,11 +32,12 @@ # Node SSL Checker

| Option | Default | Description |
| ------------------ | ------- | ------------------------------------------------- |
| method | HEAD | Can be GET too |
| port | 443 | Your SSL/TLS entry point |
| agent | default | Default HTTPS agent with { maxCachedSessions: 0 } |
| rejectUnauthorized | false | Skips authorization by default |
| Option | Default | Description |
| ------------------ | ------- | ------------------------------------------------- |
| method | HEAD | Can be GET too |
| port | 443 | Your SSL/TLS entry point |
| agent | default | Default HTTPS agent with { maxCachedSessions: 0 } |
| rejectUnauthorized | false | Skips authorization by default |
| validateSubjectAltName | false | Skips returning/validating `subjectaltname` |
```ts
sslChecker("dyaa.me", { method: "GET", port: 443 }).then(console.info);
sslChecker("dyaa.me", { method: "GET", port: 443, validateSubjectAltName: true }).then(console.info);
```

@@ -56,2 +57,4 @@

**NOTE: `validFor` is only returned if `validateSubjectAltName` is set to `true`**
#### License

@@ -58,0 +61,0 @@

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