alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

grpc-js throws "unable to get issuer certificate" error while connecting #152

Closed saravanan7mani closed 2 years ago

saravanan7mani commented 2 years ago

I am trying to test my nodejs program against LND on voltage.cloud. But the @grpc/grpc-js dependancy of "lightning" library throws the mentioned error while establishing connection.

HTTP2 94739: Http2Session : socket error [unable to get issuer certificate] HTTP2 94739: Http2Session client: destroying HTTP2 94739: Http2Session client: start closing/destroying Error: unable to get issuer certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34) at TLSSocket.emit (node:events:520:28) at TLSSocket._finishInit (node:_tls_wrap:944:8) at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) { code: 'UNABLE_TO_GET_ISSUER_CERT' } HTTP2 94739: Http2Session client: finishSessionClose D 2022-02-20T03:02:43.147Z | subchannel | (11) ### connection closed with error unable to get issuer certificate D 2022-02-20T03:02:43.147Z | subchannel | (11) ### connection closed D 2022-02-20T03:02:43.147Z | subchannel | (11) ### CONNECTING -> TRANSIENT_FAILURE

It seems grpc-js library uses NodeJS TLS codes to handle TLS connection. I am not sure if its happening because of voltage's TLS cert (They use CA provided cert). But when I tried with deprecated https://www.npmjs.com/package/grpc library with a sample program (https://api.lightning.community/?javascript#getnodeinfo), i was able to connect with voltage's LND.

Can you guide me here. My goal is to connect ln-service to a remote LND.

alexbosworth commented 2 years ago

what are you specifying for the cert, can you share any code?

saravanan7mani commented 2 years ago

const {lnd} = lnService.authenticatedLndGrpc({ cert: "base64 of tls file downloaded from voltage", macaroon: "base64 of admin.macaroon downloaded from voltage", socket: "grpc endpoint uri of voltage node" });

Please note, voltage's TLS cert file is actually CA provided.

alexbosworth commented 2 years ago

OK: try omitting the cert

saravanan7mani commented 2 years ago

Did that already. Received the below error.

D 2022-02-20T03:57:39.203Z | call_stream | [0] HTTP/2 stream closed with code 0 D 2022-02-20T03:57:39.203Z | call_stream | [0] ended with status: code=13 details="Received RST_STREAM with code 0" D 2022-02-20T03:57:39.203Z | subchannel_refcount | (12) ### callRefcount 4 -> 3 [ 503, 'FailedToRetrieveNodeDetails', { err: Error: 13 INTERNAL: Received RST_STREAM with code 0 at Object.callErrorFromStatus (/Users/samani2/projects/btc/test/node_modules/ln-service/node_modules/@grpc/grpc-js/build/src/call.js:31:26) at Object.onReceiveStatus (/Users/samani2/projects/btc/test/node_modules/ln-service/node_modules/@grpc/grpc-js/build/src/client.js:180:52) at Object.onReceiveStatus (/Users/samani2/projects/btc/test/node_modules/ln-service/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141) at Object.onReceiveStatus (/Users/samani2/projects/btc/test/node_modules/ln-service/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181) at /Users/samani2/projects/btc/test/node_modules/ln-service/node_modules/@grpc/grpc-js/build/src/call-stream.js:160:78 at processTicksAndRejections (node:internal/process/task_queues:78:11) { code: 13, details: 'Received RST_STREAM with code 0', metadata: [Metadata] } } ]

alexbosworth commented 2 years ago

OK I think this error comes from the server side so something is going on there, maybe you could ask voltageio for some advice?

Another thing to try is use an existing script like https://github.com/alexbosworth/balanceofsatoshis which uses ln-service: https://docs.voltage.cloud/balance-of-satoshis-guides/balance-of-satoshis - if that works then you could see how it is calling into the methods

saravanan7mani commented 2 years ago

Thanks. I will try those and update.

saravanan7mani commented 2 years ago

Removal of cert property worked.