I am building an android app using flutter. The backend service is built using golang with gRPC as the API.
I want to achieve two-way TLS encryption for the app I am building. I have generated an RSA public and private key pair and assigned the private key to the golang gRPC side and the public key to the flutter side. I don't know if this is the best approach as I am directly storing the public key in assets
folder of my flutter app.
What is the best approach for me to achieve two-way encryption without the risk of compromising my public key, or is there any other better method altogether to achieve what I am looking for?
golang gRPC init code:
cred, sslErr := credentials.NewServerTLSFromFile(parsedConfig.GRPCConf.CertFile, parsedConfig.GRPCConf.KeyFile)
if sslErr != nil {
sslErr = errors.Wrap(sslErr, "[ERROR - 301]")
return sslErr
}
opts = append(opts, grpc.Creds(cred))
opts = append(opts, grpc.UnaryInterceptor(unaryInterceptor))
grpcServer := grpc.NewServer(opts...)