GRPC Golang Server and NodeJS client. TLS connect failed

Tjs :

Everything works fine when I don't use TLS. But when I do, it does not connect. More details:

I have configured the Golang GRPC server exactly like how this blog says https://bbengfort.github.io/programmer/2017/03/03/secure-grpc.html in Mutual TLS with Certificate Authority section. The server is up and running just fine.

Now I have a client written in NodeJS, trying to send some data through grpc. I have configured the NodeJS like below:

var PROTO_PATH = __dirname + '/protos/log.proto';
var grpc = require('grpc');
var protoLoader = require('@grpc/proto-loader');
var packageDefinition = protoLoader.loadSync(
    PROTO_PATH,
    {keepCase: true,
     longs: String,
     enums: String,
     defaults: true,
     oneofs: true
    });
    
var ssl_creds = grpc.credentials.createSsl(fs.readFileSync('ssl/ca.crt'), fs.readFileSync('ssl/client.key'), fs.readFileSync('ssl/client.crt'));

var log_proto = grpc.loadPackageDefinition(packageDefinition).log;
var client = new log_proto.LogData('<IP>:<PORT>',ssl_creds); 

I created the certificates like how it is mentioned here: https://github.com/grpc/grpc/issues/6757. Ofcourse, i did see this comment: https://github.com/grpc/grpc/issues/6757#issuecomment-264617793.

I am still seeing the error when I run NodeJS client:

{ Error: 14 UNAVAILABLE: Connect Failed
at Object.exports.createStatusError (/app/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (/app/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/app/node_modules/grpc/src/client_interceptors.js:845:24)
code: 14,
metadata: Metadata { _internal_repr: {} },
details: 'Connect Failed' }

Certificate details: SSLv3 TLSv1.2

EDIT:

I added env variable GRPC_VERBOSITY as DEBUG and found the following: Peer name <IP> is not in peer certificate

Tjs :

So the issue was that the certificate couldn't hold IP address as the hostname. It should have a name and not an IP - fixed it by providing a name and overriding the target name.

const options = {
  'grpc.ssl_target_name_override' : 'simple-host',
  'grpc.default_authority': 'simple-host'
};
var client = new log_proto.LogData('<IP>:<PORT>',ssl_creds,options); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

gRPC client failing to connect to server with TLS certificates

Golang : "Err TLS Handshake failed: tls: server selected unsupported protocol version 301" when trying to connect to sql server (diferent host)

Proto mismatch in GRPC client server architecture in golang

Connect to MySQL server for client failed

Golang HTTPS/TLS POST client/server

Starting a socket server interferes with the gRPC/http client server communication Golang

NodeJS Express JS - MongoError: failed to connect to server

Reuse log client in interceptor for Golang grpc server method

access golang websocket server with nodejs client

grpc server ruby with TLS/SSL

nodejs typescript grpc server

GRPC - nodejs DNS resolution failed

How to configure gRPC Client communicating over TLS transport layer without server certificate?

Python ssl unable to connect to TLS1.2 server with TLS1.2 client

Nodejs connect to mongoose failed on server(ubuntu), but worked on local

Java gRPC - TLS - how to set up mutual TLS on the client side?

Failed to connect to shadowsocks client

unable to connect to nodejs server from react client with SocketIO

gRPC server error handler golang

Transport failed error when using a Java based Grpc server with a C# based client

Raising a server error to the client with grpc

gRPC Python Server calling Client?

Detect a GRPC Server Failure in NodeJS

Enable compression in nodejs grpc server

How can I connect a gRPC client in .NET framework with a secure .NET Core server?

gRPC: 14 UNAVAILABLE: failed to connect to all addresses

Golang connection to SQL Server error - "TLS Handshake failed: Cannot read handshake packet: EOF"

Requests failing to connect to a TLS server

Trying to understand the use of channel in gRPC client in golang