Launch Your MVP. Prove ROI. Scale Globally
00D
00H
00M
00S
Grab Deal Now!
← Back to Articles
Development / backend API development

Node.js SSL certificate validation issue

SSaurav Kumar1 Min Read
Node.js SSL certificate validation issue
In This Article

UNABLE_TO_VERIFY_LEAF_SIGNATURE

This is a Node.js SSL certificate validation issue. It means Node doesn’t trust the certificate chain from your local Sitecore endpoint (https://sc104sc.dev.local).

Why this happens

  • Your Sitecore instance is using a self-signed cert or a cert signed by a local CA
  • Node.js doesn’t automatically trust your OS certificate store
  • So the HTTPS request fails during SSL verification

Fix options (choose one)

Fix Critical Development Issues Before They Slow Your Delivery

Option 1 — Trust the local root CA (best long-term fix)

If you're using something like mkcert:

  1. Install the root CA into Node:
  2. export NODE_EXTRA_CA_CERTS=/path/to/rootCA.pem
  3. Then restart your dev server

This keeps SSL validation intact (recommended)

Option 2 — Disable SSL verification (quick dev-only fix)

Set this env variable:

export NODE_TLS_REJECT_UNAUTHORIZED=0

Or on Windows:

set NODE_TLS_REJECT_UNAUTHORIZED=0

Warning: This disables SSL security entirely — only use locally.

Option 3 — Pass custom HTTPS agent in code

If you're using fetch (Node):

import https from "https";

const agent = new https.Agent({

rejectUnauthorized: false,

});

fetch("https://sc104sc.dev.local/...", { agent });

Option 4 — Install cert into Node manually

If you have the .crt file:

NODE_EXTRA_CA_CERTS=./sitecore.crt npm run dev

Quick sanity checks

  • Open https://sc104sc.dev.local in your browser
    • If you see a warning → cert isn’t trusted
  • If browser works but Node fails → classic Node CA issue

Recommendation

Use Option 1 (NODE_EXTRA_CA_CERTS) if:

  • you're working in a proper local dev setup (Sitecore XM/XP, containers, etc.)

Use Option 2 only if:

  • you just need to unblock quickly

Frequently Asked Questions

What is Node.js SSL certificate validation issue?

Learn how to fix Node.js SSL certificate error UNABLE_TO_VERIFY_LEAF_SIGNATURE. Step-by-step solutions using NODE_EXTRA_CA_CERTS, HTTPS agent, and dev fixes.

Reader Responses

Join the Conversation

Fix Node.js SSL Error UNABLE_TO_VERIFY_LEAF_SIGNATURE