错误:UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap安装

 mobiledu2502918317 发布于 2023-02-08 14:10

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

任何帮助,将不胜感激.

2 个回答
  • 我得到了同样的错误,因为我在公司防火墙/代理后面,我的连接通过了代理的证书.

    在命令行中运行:

    npm config set strict-ssl false
    

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

    npm config set strict-ssl true
    

    把它重新打开.

    ref:https://thomashunter.name/blog/npm-ssl-errors/

    2023-02-08 14:13 回答
  • 这可以在不禁用严格SSL的情况下修复,但这并非易事.

    查找实际使用的证书,可能是您在公司SSL拦截代理之后.您可以使用浏览器,某些CLI工具等.我最终certmgr.msc在Windows中运行,因为证书通过组策略分发并导出为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文件,并注意顺序从叶根.

    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
    

    2023-02-08 14:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有