代码之家  ›  专栏  ›  技术社区  ›  Zack

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

  •  0
  • Zack  · 技术社区  · 6 年前

    作为背景,我将跟随 this 教程,尝试使节点示例正常工作。

    我已经下载了文件夹,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
    

    似乎与此相关。

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

    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;    
    

    试图跟随 this 模式。我仍然看到同样的问题。 有人有什么想法吗?我应该提到我运行的是node版本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
    

    似乎不管库是什么,它都失败了,我试着更新我的代理设置 here . 似乎没有帮助。

    编辑3:

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

    1 回复  |  直到 6 年前
        1
  •  1
  •   Zack    6 年前

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

    cafile=<my cert file>
    

    而且npm安装也成功了。我不确定为什么我朋友的安装工作,因为他甚至没有这个文件,但这是足够好的时间。