Expect-CT Header Middleware

1.0.0 · deprecated · verified Wed Apr 22

The `expect-ct` package provides Express middleware for setting the deprecated Expect-CT HTTP response header. This header was designed to enforce Certificate Transparency (CT) requirements by instructing browsers to expect valid Signed Certificate Timestamps (SCTs) for a website's TLS certificates. However, the Expect-CT header itself has been deprecated by major browsers (e.g., Chrome removed support in version 107 in October 2022) as Certificate Transparency is now a baseline requirement enforced by default across all publicly trusted certificates. As such, this middleware, currently at version 1.0.0 (though `1.0.1` is on npm, published 3 years ago), offers minimal practical security benefit for modern web applications. The Helmet.js project, which originally included this functionality, removed `expect-ct` from its default middlewares in Helmet v5 due to its obsolescence.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to integrate `expect-ct` middleware into an Express application to set the Expect-CT header, including options for `maxAge`, `enforce`, and `reportUri`.

import express from 'express';
import expectCt from 'expect-ct';

const app = express();
const port = process.env.PORT ?? 3000;

// Sets Expect-CT: max-age=123
app.use(expectCt({ maxAge: 123 }));

// Optionally, enforce and report
app.use(
  expectCt({
    enforce: true,
    maxAge: 30,
    reportUri: 'https://example.com/report' // Replace with your actual reporting endpoint
  })
);

app.get('/', (req, res) => {
  res.send('Hello, Expect-CT!');
});

app.listen(port, () => {
  console.log(`Server listening on port ${port}`);
  console.warn('The Expect-CT header is largely deprecated and may not provide significant security benefits in modern browsers.');
});

view raw JSON →