无法验证第一个证书(grpc/节点)



对于一些背景,我正在按照本教程进行操作,试图让节点示例正常工作。

我已经下载了该文件夹,cd到目录中,并尝试运行npm安装

我得到以下堆栈跟踪。

npm WARN package.json grpc-examples@0.1.0 No repository field.
npm WARN package.json grpc-examples@0.1.0 No license field.

> grpc@1.12.2 install /tmp/grpc/examples/node/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp WARN Tried to download(400): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.12.2/node-v46-linux-x64-glibc.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for grpc@1.12.2 and node@4.5.0 (node-v46 ABI, glibc) (falling back to source compile with node-gyp) 
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: unable to verify the first certificate
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1022:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:586:8)
gyp ERR! stack     at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onnewsession.ssl.onhandshakedone (_tls_wrap.js:428:38)
gyp ERR! System Linux 4.8.13-100.fc23.x86_64
gyp ERR! command "/home/nbkiq0w/.nvm/versions/node/v4.5.0/bin/node" "/home/nbkiq0w/.nvm/versions/node/v4.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--libr$ry=static_library" "--module=/tmp/grpc/examples/node/node_modules/grpc/src/node/extension_binary/node-v46-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/tmp/grpc/examples/node/node_mo$ules/grpc/src/node/extension_binary/node-v46-linux-x64-glibc" "--node_abi_napi=node-v46"

堆栈跟踪还有更多内容,但我认为这得到了它的要点。

Unable to verify the first certificate

在这里似乎相关。

我用谷歌搜索了一下,发现了这个,这似乎解决了我的问题。我修改了示例源代码,

examples/node/dynamic_codegen/greeter_server.js

因此,它现在已将以下内容添加到现有文件的顶部。

var rootCas = require('ssl-root-cas/latest').create();                                                                                                                                                             
rootCas                                                                                                                                                                                                            
.addFile('/etc/pki/ca-trust/source/anchors/amrs-g2.cer');                                                                                                                                                        
require('https').globalAgent.options.ca = rootCas;    

试图遵循此模式。我仍然看到同样的问题。 有人有什么想法吗?我应该提到我正在运行节点版本 4.5.0 和 npm 版本 2.15.9。

我尝试弄乱版本,但无法使其工作。

编辑 1:

已尝试将节点版本更新到 10.0.0 Npm 版本 5.6.0

再次尝试npm安装,这次出现一个奇怪的错误...

npm install
npm ERR! code E418
npm ERR! 418 I'm a teapot: async@^1.5.2

编辑2:

尝试一遍又一遍地运行该命令,似乎它失败的库或多或少是随机的。

npm ERR! code E418
npm ERR! 418 I'm a teapot: grpc@^1.0.0
^C
[nbkiq0w@localhost node]$ npm install 
npm ERR! code E418
npm ERR! 418 I'm a teapot: google-protobuf@^3.0.0
^C
[nbkiq0w@localhost node]$ npm install 
npm ERR! code E418
npm ERR! 418 I'm a teapot: lodash@^4.6.1
^C
[nbkiq0w@localhost node]$ npm install 
npm ERR! code E418
npm ERR! 418 I'm a teapot: grpc@^1.0.0
^C
[nbkiq0w@localhost node]$ npm install 
npm ERR! code E418
npm ERR! 418 I'm a teapot: lodash@^4.6.1

似乎无论库如何,它都会失败,我尝试更新我的代理设置,如下所示。似乎没有帮助。

编辑 3:

切换回节点 6.12.0,并看到原始 TLS 错误。我的一个朋友能够按原样下载节点目录,并在他的机器上运行(使用 6.12.0(,所以它一定是与我的机器隔离的东西。

我在另一页上找到了一些建议来调整在我的主目录中找到的.npmrc文件。我添加了以下行

cafile=<my cert file>

并且 npm 安装有效。我不确定为什么我朋友的安装有效,因为他甚至没有这个文件,但这暂时足够好了。

最新更新