node.js 错误:UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap 安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20747817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap Installation
提问by Dozent
I'm trying to install Phonegap in Ubuntu. The installation of NodeJS was successful, however I can't install Phonegap itself. Here is the error output of terminal:
我正在尝试在 Ubuntu 中安装 Phonegap。NodeJS安装成功,但是Phonegap本身无法安装。这是终端的错误输出:
test@test-VirtualBox:~$ sudo npm install -g phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/phonegap
npm ERR! Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! at SecurePair.<anonymous> (tls.js:1350:32)
npm ERR! at SecurePair.EventEmitter.emit (events.js:92:17)
npm ERR! at SecurePair.maybeInitFinished (tls.js:963:10)
npm ERR! at CleartextStream.read [as _read] (tls.js:463:15)
npm ERR! at CleartextStream.Readable.read (_stream_readable.js:320:10)
npm ERR! at EncryptedStream.write [as _write] (tls.js:366:25)
npm ERR! at doWrite (_stream_writable.js:219:10)
npm ERR! at writeOrBuffer (_stream_writable.js:209:5)
npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:180:11)
npm ERR! at write (_stream_readable.js:573:24)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /home/test/npm-debug.log npm
npm ERR! System Linux 3.11.0-14-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "phonegap"
npm ERR! cwd /home/test
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/test/npm-debug.log
npm ERR! not ok code 0
Any help would be appreciated.
任何帮助,将不胜感激。
回答by jdmonty
I got the same error, given I was behind a corporate firewall/proxy and my connection was passed the proxy's certificate.
我遇到了同样的错误,因为我在公司防火墙/代理后面,并且我的连接通过了代理的证书。
In your command line run:
在您的命令行中运行:
npm config set strict-ssl false
NOTE: that this is not best practice to blindly accept untrusted or invalid SSL certificates, which is what the command does (turn off certificate checking). You can run
注意:这不是盲目接受不受信任或无效的 SSL 证书的最佳做法,这正是该命令所做的(关闭证书检查)。你可以跑
npm config set strict-ssl true
to turn it back on.
将其重新打开。
回答by Adam
This can be fixed without disabling strict SSL, however it is non-trivial.
这可以在不禁用严格的 SSL 的情况下修复,但是这很重要。
Findthe certificates actually being used, likely you're behind a corporate SSL intercepting proxy. You might be able to use a browser, some CLI tool etc. I ended up running certmgr.mscin Windows as the certificates are distributed via Group policy and export as p7b files.
查找实际使用的证书,很可能您在使用企业 SSL 拦截代理。您也许可以使用浏览器、一些 CLI 工具等。我最终certmgr.msc在 Windows 中运行,因为证书通过组策略分发并导出为 p7b 文件。
Convertthe certificates if necessary, I used openssl tool to convert from p7b to PEM (aka .crt)
如有必要,转换证书,我使用 openssl 工具从 p7b 转换为 PEM(又名 .crt)
openssl pkcs7 -print_certs -inform DER -in /mnt/adam/certs/my-company-root.p7b -outform PEM -out my-company-root.crt
Merge, if there is more than one certificate, into a single PEM file, taking care to order from leaf to root.
合并,如果有一个以上的证书,到一个单一的PEM文件,并注意顺序从叶根。
cat my-company-leaf.crt my-company-intermediate.crt my-company-root.crt > my-company-single.crt
Configurenpm at the certificate file
在证书文件中配置npm
npm config set cafile my-company-single.crt
(or globally)
(或全球)
sudo npm config set -g cafile my-company-single.crt
回答by jlucasps
running
跑步
npm config set strict-ssl false
solved my problem.
解决了我的问题。
I'm using Vagrant (Linux precise32 Ubuntu ), and Windows 7 as host.
我使用 Vagrant(Linux precision32 Ubuntu)和 Windows 7 作为主机。
Thanks
谢谢
回答by user12709614
in case anyone is as clumsy as me, I got UNABLE_TO_VERIFY_LEAF_SIGNATUREon npm installwhen I forgot to add the git+before the url of my project.
万一有人是因为笨拙我,我UNABLE_TO_VERIFY_LEAF_SIGNATURE就npm install当我忘了加上git+我的项目的URL之前。
I had
我有
npm install --save https://myserv.er/my/project-path.git
instead of
代替
npm install --save git+https://myserv.er/my/project-path.git

