You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node.js应用中Application Insights CorrelationIdManager证书验证错误求助

Fixing Application Insights' UNABLE_TO_VERIFY_LEAF_SIGNATURE Error in Node.js

Hey there, let’s work through this certificate error you’re hitting with Application Insights. That UNABLE_TO_VERIFY_LEAF_SIGNATURE error almost always means Node.js can’t validate the full SSL certificate chain for the Application Insights endpoint—usually because of a corporate proxy, missing intermediate certificates, or self-signed certs in your environment. Here are practical fixes to try:

Quick Test Environment Fix (Not for Production)

If you just need to get things working in a test setup and can temporarily bypass certificate validation (never do this in production), configure the Application Insights HTTP client to skip checks:

const appInsights = require('applicationinsights');
appInsights.setup('<your-instrumentation-key>')
  .setAutoCollectDependencies(true)
  .setAutoCollectRequests(true)
  .setSendLiveMetrics(true)
  .setHttpClient({
    rejectUnauthorized: false // Disables SSL certificate validation
  })
  .start();

Production-Safe Fix: Add Missing Certificates

If the issue is a missing root or intermediate certificate (common in corporate networks), tell Node.js to trust the required certificate:

  1. Get the PEM-formatted certificate file for your proxy or internal CA.
  2. Set the NODE_EXTRA_CA_CERTS environment variable:
    • On Linux/macOS:
      export NODE_EXTRA_CA_CERTS="/path/to/your/certificate.pem"
      
    • On Windows (PowerShell):
      $env:NODE_EXTRA_CA_CERTS = "C:\path\to\your\certificate.pem"
      

This makes Node.js include your custom certificate in its trusted chain, allowing proper validation of the Application Insights endpoint.

Fix Proxy Configuration

If your app uses a proxy to access external services, ensure Application Insights is configured to use it:

  1. First install the https-proxy-agent package:
    npm install https-proxy-agent
    
  2. Update your Application Insights setup to use the proxy agent:
    const appInsights = require('applicationinsights');
    const HttpsProxyAgent = require('https-proxy-agent');
    
    appInsights.setup('<your-instrumentation-key>')
      .setHttpClient({
        agent: new HttpsProxyAgent('http://your-proxy-address:port')
      })
      .start();
    

Give these steps a shot—one of them should get your Application Insights working without that certificate error!

内容的提问来源于stack exchange,提问作者jack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:02:57