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
| Name | Type | Description |
|---|---|---|
| hostname | string | Expected host name. |
| cert | object | Peer 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);