Cert Paste Check

Tells a certificate, key and CSR apart as they're pasted and catches chain, expiry, hostname and key-mismatch mistakes before a TLS install breaks.

StopsBroken TLS chain in production

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/cert-paste-check.json

The files land in your project. They're yours to edit.

Usage

cert-paste-check-usage.tsx
import { base64ToBytes, CertPasteCheck, parseCertificate } from "@/components/ui/cert-paste-check"

<CertPasteCheck value={value} onValueChange={setValue} hostname={hostname} privateKey={LEAF_KEY} production now={NOW} timeZone="Asia/Kolkata" />

What it catches

  • A private key or CSR pasted where a certificate was expected
  • A chain out of order or missing its intermediate
  • Expired or soon-expiring certificates (warnDays)
  • A hostname the SANs don't cover, including wildcard and CN-only traps
  • A self-signed certificate in production, and a private key that doesn't match

Props

CertPasteCheck props
PropTypeDefault
value

Controlled PEM text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the new text on every edit or fix.

(value: string) => void—
expect

What the field is for. "chain" (default) takes a certificate plus intermediates.

CertCheckOptions["expect"]"chain"
hostname

The domain the certificate must cover, e.g. "acme.com".

string—
privateKey

The private key from a sibling field, matched against the certificate. Never shown.

string—
production

Self-signed certificates become errors.

booleanfalse
warnDays

Warn when fewer days than this remain. Default 30.

number30
now

Fixed "now" for tests and demos. Otherwise the clock once mounted.

Date | number—
timeZone

IANA time zone for dates. Defaults to the user's own.

string—
locale

Locale for dates.

string—
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string. `{name}`, `{host}`, `{date}`, `{span}`, `{days}`, `{detail}`, `{subject}`, `{count}` are filled in.

Partial<CertPasteCheckMessages>—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Labelled textarea with aria-invalid and aria-describedby to the hint and report
  • Summary in a role="status" region; serious problems use role="alert"
  • After a fix, focus moves to the next fix or back to the field
  • Severity shown with icons and text

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Validate the full chain and key on the server or in your TLS tooling before deploying; this is a paste-time check.

  • Parses the DER structure only; signatures are not verified and revocation is not checked
  • Does not check that the root is trusted by browsers
  • Everything runs in the browser, but a pasted private key is still sensitive: avoid logging the field

What it stops

Broken TLS chain in production

Also known as

ssl certificate · tls · pem · csr · private key · fullchain · intermediate · lets encrypt

Dependencies

Pairs well with