TLS

tls.checkServerIdentity()

Check a host name against certificate identifiers; not a standalone chain validation function. Local Node 22.16.0; production target compatibility pending. See https://nodejs.org/download/release/v22.16.0/docs/api/tls.html.

Formal Syntax & Structure

nodejs syntaxnodejs
tls.checkServerIdentity(hostname, cert)

Parameters & Attributes

NameTypeDescription
hostnamestringExpected host name.
certobjectPeer certificate information.

Return Value

Error | undefined

Result or receiver of the documented operation; see the linked versioned API contract.

Working Example

Example Snippetnodejs
import { checkServerIdentity } from 'node:tls';const cert={subjectaltname:'DNS:catalog.example.test'};console.log(checkServerIdentity('catalog.example.test',cert)===undefined);
Node.js Reference