Need private packages and team management tools?Check out npm Teams »

@litert/tls-sni

0.3.1 • Public • Published

LiteRT/TLS-SNI

npm version License node GitHub issues GitHub Releases

A TLS SNI(Server Name Indication) library for Node.js.

Features

  • TypeScript Supports.
  • X.509 Certificate Decoder
  • Partial DER Decoder
  • Certificate Manager
  • Graceful Update Certificate.
  • ECC Certificate Supports.

Requirement

  • TypeScript v3.2.x (or newer)
  • Node.js v10.0.0 (or newer)

Installation

npm i @litert/tls-sni --save

Usage

import * as libsni from "@litert/tls-sni";
import * as TLS from "tls";
import * as FS from "fs";
 
// 1. Create a certificate mananger object.
const cm = libsni.certs.createManager();
 
// 2. Load a certificate into certificate mananger
cm.use(
    "default",
    FS.readFileSync(`./certs/default/cert-20190801.pem`),
    FS.readFileSync(`./certs/default/key-20190801.pem`)
);
 
// 3. Create a TLS server with the SNI callback provided by ceritificate manager.
const server = TLS.createServer({
    SNICallback: cm.getSNICallback(),
    ...otherOptions
});
 
// ...
 
// 4. Check if there are some certificates outdating.
 
const outdatingCerts = cm.findExpiringCertificates(
    Date.now() + 28 * 86400000 // Optional, 7 days by default
); // Get the list of certificate names, which are outdating in 28 days.
 
// ...
 
// 5. When a cert is being outdated, replace it with a new one.
cm.use(
    "default",
    FS.readFileSync(`./certs/default/cert-20190901.pem`),
    FS.readFileSync(`./certs/default/key-20190901.pem`)
);

Document

Preparing yet.

License

This library is published under Apache-2.0 license.

Install

npm i @litert/tls-sni

DownloadsWeekly Downloads

8

Version

0.3.1

License

Apache-2.0

Unpacked Size

194 kB

Total Files

110

Last publish

Collaborators

  • avatar