我们有一个带SSL的Squid代理,使用自签名证书和ca-bundle.cert。尝试安装时,仅最近的NPM安装开始失败
npm --registry https://registry.npmjs.org \
--proxy http://localhost:10080 --https-proxy http://localhost:10443 \
--ddd安装快递
产生错误-
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
任何想法或指针将不胜感激。
第一次回复
我在squid.conf中添加了“ dns_v4_first on”,现在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
如果在外壳中而不是通过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?
最佳答案
似乎squid正在尝试仅使用IPv4的主机上通过IPv6连接:
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
关于npm - NPM安装无法通过带有UNABLE_TO_VERIFY_LEAF_SIGNATURE的Squid代理进行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51593730/