【问题标题】:Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap Installation错误:UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap 安装
【发布时间】:2014-01-11 22:11:15
【问题描述】:

我正在尝试在 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

任何帮助将不胜感激。

【问题讨论】:

    标签: node.js cordova npm ubuntu-13.10


    【解决方案1】:

    确保 root 具有配置属性。

    使用 sudo 时,您是在为 root 配置的环境下运行的。 Root 可能没有相同的节点配置,并且可能不知道您的证书。尝试使用 -E 将您的环境配置传递给 root:

    $ sudo -E npm install -g phonegap
    

    【讨论】:

      【解决方案2】:

      您还可以使用节点环境变量在您的代码中禁用 SSL 检查:

      在您的 index.js 文件中,添加:

      process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

      请注意,这不是一个好习惯,因为它不会尝试检查 https 证书的有效性

      【讨论】:

        【解决方案3】:

        如果有人像我一样笨拙,当我忘记在我的项目网址前添加git+ 时,我在npm install 上得到了UNABLE_TO_VERIFY_LEAF_SIGNATURE

        我有

        npm install --save https://myserv.er/my/project-path.git
        

        而不是

        npm install --save git+https://myserv.er/my/project-path.git
        

        【讨论】:

          【解决方案4】:

          我遇到了同样的错误,因为我在公司防火墙/代理后面,并且我的连接通过了代理的证书。

          在你的命令行运行:

          npm config set strict-ssl false
          

          注意:这不是盲目接受不受信任或无效的 SSL 证书的最佳做法,这是命令的作用(关闭证书检查)。你可以运行

          npm config set strict-ssl true
          

          重新打开它。

          参考:https://thomashunter.name/blog/npm-ssl-errors/

          【讨论】:

          • 谢谢 .. 它在使用 npm 安装 Angular CLI 的情况下也有效。
          • 谢谢!我花了整个上午试图找到解决方案
          【解决方案5】:

          可以在不禁用严格 SSL 的情况下解决此问题,但这并不重要。

          查找实际使用的证书,您可能是behind a corporate SSL intercepting proxy。您可能可以使用浏览器、某些 CLI 工具等。我最终在 Windows 中运行 certmgr.msc,因为证书通过组策略分发并导出为 p7b 文件。

          转换如有必要,我使用 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
          

          合并,如果有多个证书,则合并到一个 PEM 文件中,taking care to order from leaf to root.

          cat my-company-leaf.crt my-company-intermediate.crt my-company-root.crt > my-company-single.crt
          

          在证书文件中配置 npm

          npm config set cafile my-company-single.crt
          

          (或全局)

          sudo npm config set -g cafile my-company-single.crt
          

          【讨论】:

          • 刚刚试了一下,效果很好!对我来说,这比完全禁用 ssl 要好得多……你不知道将来会发生什么。感谢您的解决方案:)
          【解决方案6】:

          运行

          npm config set strict-ssl false
          

          解决了我的问题。

          我使用 Vagrant(Linux 精确 32 Ubuntu)和 Windows 7 作为主机。

          谢谢

          【讨论】:

            猜你喜欢
            • 2014-07-27
            • 2015-01-29
            • 1970-01-01
            • 2013-08-12
            • 2018-10-28
            • 2013-08-05
            • 2014-07-28
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多