Node.js SSL certificate validation issue

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:
- Install the root CA into Node:
- export NODE_EXTRA_CA_CERTS=/path/to/rootCA.pem
- 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.


