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

使用Heroku CLI时遭遇SELF_SIGNED_CERT_IN_CHAIN错误的解决咨询

Fixing the SELF_SIGNED_CERT_IN_CHAIN Error in Heroku CLI

Hey there, I’ve dealt with this exact headache multiple times—usually when working behind a corporate proxy, using local SSL inspection tools, or with outdated CLI versions. Let’s break down the solutions from quick (but risky) to proper, long-term fixes:

If you just need to run a command urgently and don’t mind skipping SSL verification temporarily:

  • On Linux/macOS: Run this in your terminal first:
    export NODE_TLS_REJECT_UNAUTHORIZED=0
    
  • On Windows Command Prompt:
    set NODE_TLS_REJECT_UNAUTHORIZED=0
    
  • On Windows PowerShell:
    $env:NODE_TLS_REJECT_UNAUTHORIZED=0
    

Important: Remember to revert this after you’re done! Use unset NODE_TLS_REJECT_UNAUTHORIZED (Linux/macOS) or set NODE_TLS_REJECT_UNAUTHORIZED= (Windows cmd) to re-enable SSL security.

Proper Long-Term Fix: Configure Trusted CA Certificates

This is the safe, sustainable approach—tell Heroku CLI to trust your network’s self-signed certificate:

  1. Locate your organization’s CA certificate file (usually a .pem or .crt file). If you’re on a Linux system, you can often use the system’s default CA bundle with this command to get its path:
    openssl version -d | cut -d'"' -f2
    
    The cert file is usually named cert.pem in that directory.
  2. Set the HEROKU_SSL_CERT environment variable to point to your CA file:
    • Linux/macOS (add this to your ~/.bashrc, ~/.zshrc, etc., to make it permanent):
      export HEROKU_SSL_CERT="/full/path/to/your/ca-cert.pem"
      
    • Windows (add this to your system environment variables to make it permanent):
      set HEROKU_SSL_CERT="C:\full\path\to\your\ca-cert.pem"
      
  3. Restart your terminal and test the Heroku commands again—they should now trust the certificate chain.

Update Heroku CLI to the Latest Version

Outdated CLI versions sometimes have outdated root CA certificates that don’t trust newer valid certificates. Update it with:

heroku update

If the update command itself fails due to the same SSL error, download the latest installer directly from Heroku’s official distribution sources.

Check Proxy/Firewall Settings

If you’re on a corporate network, your proxy might be intercepting SSL traffic. Make sure Heroku CLI is configured to use your proxy:

  • Set the http_proxy and https_proxy environment variables:
    • Linux/macOS:
      export http_proxy=http://your-proxy-host:port
      export https_proxy=http://your-proxy-host:port
      
    • Windows:
      set http_proxy=http://your-proxy-host:port
      set https_proxy=http://your-proxy-host:port
      
  • If your proxy requires authentication, include your credentials in the URL: http://username:password@proxy-host:port

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 06:46:00