0

I am using NextJS to build my web application with https://github.com/improbable-eng/grpc-web for communication between backend and frontend. The following React element uses grpc.invoke to communicate with GRPC backend service:

export default function Index({user}: OverviewProps) {

    useEffect(() => {
        grpc.invoke(RepoService.ListRepos, {
            host: "http://localhost:9000",
            request: listReq,
            onMessage: (msg) => {
                console.log(msg);
            },
            onEnd:(code:grpc.Code,msg:string | undefined | number, trailers: grpc.Metadata)=>{
                console.log(code);
                if(code == grpc.Code.OK){
                    console.log("Worked")
                }else{
                    console.log("Not Working")
                }
            },
            debug: true

        })

    }, [])

    return wrapWithLayout(
        <p>Hi {user.nickname}</p>
    );
}

The backend service is secured with TLS. On the client-side, I have to load somehow the certificate into the client. The question is, how to load the certificate into the client-side that it can communicate with the backend service?

softshipper
  • 32,463
  • 51
  • 192
  • 400

1 Answers1

0

In the browser client any TLS options have to be configured on the browser level, because we don't have access to the underlying network like you might have on other platforms. This essentially means that you will need to configure your server with a publically acceptable certificate (e.g. Let's Encrypt or one bought from a CA directly).

Source

Riwen
  • 4,734
  • 2
  • 19
  • 31
  • Assume, when I choose to go with `Let's Encrypt` what exactly do I have to do? – softshipper May 18 '21 at 20:02
  • That's a pretty broad topic, worthy of a question on its own. Although I'm pretty sure a simple search will answer it for you. Edit: there's nothing special about Let's Encrypt - except for the fact that it's a free provider that issues certificates using the ACME protocol. – Riwen May 18 '21 at 20:03