tls.checkServerIdentity()
The Node.js function that checks whether a certificate is valid for a given host name, returning an Error if it is not.
In more detail
Node.js calls it automatically on client connections; you can call or replace it to add rules, such as pinning. It compares the host name with the certificate's Subject Alternative Names, including wildcard rules.
Related terms
- Subject Alternative Name — The certificate field that lists every host name, and sometimes IP address, the certificate is valid for.
- TLS certificate — A signed digital document that proves a server really owns a domain name and holds the key used to start encrypted TLS connections.
- man-in-the-middle attack — An attack where someone secretly sits between two parties, relaying and possibly altering their traffic while each thinks it talks to the other.
Taught in
- TLS & HTTPS Encryption: Certificates & SNI Contexts — Node.js Internals & Backend Services