gpt4 book ai didi

通过 Squid 代理进行 NPM 安装失败并出现 UNABLE_TO_VERIFY_LEAF_SIGNATURE

转载 作者:行者123 更新时间:2023-12-01 22:16:30 26 4
gpt4 key购买 nike

我们有一个带有 SSL 的 Squid 代理,使用自签名证书和 ca-bundle.cert。直到最近,NPM 安装在尝试安装时才开始失败

npm --registry https://registry.npmjs.org\--代理http://localhost:10080 --https-代理 http://localhost:10443\--ddd 安装 Express

产生错误 -

npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://registry.npmjs.org/express failed,
reason: unable to verify the first certificate

Squid 正在 Docker 中运行,其日志显示

NONE/200 0 CONNECT registry.npmjs.org:443 - HIER_DIRECT

任何想法或指示将不胜感激。

第一次回复响应

我将“dns_v4_first on”添加到了squid.conf,现在NPM错误消息是

npm verb node v8.9.3
npm verb npm v5.5.1
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
npm ERR! request to https://registry.npmjs.org/express failed, reason: self signed certificate in certificate chain

其他信息

我发现 NPM 接受代理设置时出现异常行为。当代理设置为内联时,如下所示,它会返回 HTTP 503。

npm cache clear --force && rm -rf node_modules/

npm --strict-ssl=false --registry https://registry.npmjs.org
--proxy http://example-proxy.net:3339 --https-proxy http://example-proxy.net:3339
--ddd install express

当仅设置代理而不是 https-proxy 时,它可以工作!

npm cache clear --force && rm -rf node_modules/

npm --strict-ssl=false --registry https://registry.npmjs.org
--proxy http://example-proxy.net:3339
--ddd install express

当在 shell 中设置代理而不是通过 npm 命令时,它可以工作!

export http_proxy=http://example-proxy.net:3339 
export HTTPS_PROXY=http://example-proxy.net:3339
export https_proxy=http://example-proxy.net:3339
export HTTP_PROXY=http://example-proxy.net:3339

npm cache clear --force && rm -rf node_modules/

npm --strict-ssl=false --registry https://registry.npmjs.org
--ddd install express

那么,当同时设置代理和 https-proxy 时,为什么 npm 命令会返回 HTTP 503?

最佳答案

看起来鱿鱼正在尝试通过 IPv6 在只有 IPv4 的主机上进行连接:

connect(14, {sa_family=AF_INET6, sin6_port=htons(443), inet_pton(AF_INET6, "2400:cb00:2048:1::6810:1b23", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 ENETUNREACH (Network is unreachable)
read(14, 0x7ffe450e1040, 65535) = -1 ENOTCONN (Transport endpoint is not connected)

将此选项添加到squid.conf 可以解决此问题:

dns_v4_first on

关于通过 Squid 代理进行 NPM 安装失败并出现 UNABLE_TO_VERIFY_LEAF_SIGNATURE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51593730/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com