Search code examples
grpcgrpc-node

Apply security in grpc client server node js


I am new to GRPC call, i created 1 server and client,now how to restrict other clients to connect my server

i haven't tried any solution,because not know the best solution and i have limited time to appy solution so posting question


Solution

  • you can create a server with secure credentials as mentioned here

    there are different methods there, you can choose any of it

    I prefer SSL method

    to create a connection with ssl_creds

    const root_cert = fs.readFileSync('path/to/root-cert');
    const ssl_creds = grpc.credentials.createSsl(root_cert);
    const stub = new helloworld.Greeter('myservice.example.com', ssl_creds);
    

    for generating SSL I have used git repo and follow the instruction according to README