简体   繁体   中英

Unable to verify the first certificate (grpc/node)

For some background, I am following along with this tutorial, trying to get the node example working.

I have downloaded the folder, cd'd into the directory, and tried to run npm install .

I get the following stack trace.

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"

There's a bit more to the stack trace, but I think this gets the gist of it.

Unable to verify the first certificate

seems relevant here.

I googled a bit and found this , which seems to address my issue. I modified the example source code,

examples/node/dynamic_codegen/greeter_server.js

So it now has the following added to the top of the existing file.

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;    

In an attempt to follow this pattern. I am still seeing the same issue. Anyone have any ideas? I should mention that I am running node version 4.5.0 and npm version 2.15.9.

I've tried messing around with the versions a bit, but can't get it working.

edit 1:

Tried updating node version to 10.0.0 Npm version 5.6.0

Tried the npm install again, this time got a weird error...

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

edit 2:

Tried running the command over and over, seems like the library it fails on is more or less random.

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

Seems like it just fails regardless of library, I tried updating my proxy settings like seen here . Doesn't seem to help.

edit 3:

switched back to node 6.12.0, and seeing the original tls error. One of my friends was able to download the node directory as is, and run on his machine (using 6.12.0), so it must be something isolated to my machine.

I found on another page some advice to adjust my .npmrc file found in my home directory. I added the following line

cafile=<my cert file>

And the npm install worked. I'm unsure why my friend's install worked, since he didn't even have this file, but this is good enough for the time being.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM