Skip to content

Commit

Permalink
implemented TLS for DE && FS
Browse files Browse the repository at this point in the history
Signed-off-by: aloksharma20 <[email protected]>
  • Loading branch information
aloksharma20 committed Aug 9, 2023
1 parent 74a8d62 commit ae9a1af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/libs/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func SetDefaultConfig() {
// discoveredPolicy config
viper.SetDefault("dsp.auto-deploy-dsp", true)

//Feeder Service TLS COnfiguration
viper.SetDefault("feederservice.enable", false)

}

type cfgArray []string
Expand Down
18 changes: 11 additions & 7 deletions src/server/grpcServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,7 @@ func (ps *publisherServer) GetSummary(req *ppb.SummaryRequest, srv ppb.Publisher
func StartGrpcServer() *grpc.Server {
var s *grpc.Server
if viper.GetBool("feederservice.enable") {
certFile := viper.GetString("feederservice.tls.cert.file")
keyFile := viper.GetString("feederservice.tls.key.file")
creds, err := credentials.NewServerTLSFromFile(certFile, keyFile)
if err != nil {
log.Error().Msgf("Unable to read tls certificate credentails :: %s", err)
}
s = grpc.NewServer(grpc.ServerOption(grpc.Creds(creds)))
s = grpc.NewServer(grpc.ServerOption(grpc.Creds(GetTLSCredentails())))
} else {
s = grpc.NewServer()
}
Expand Down Expand Up @@ -376,3 +370,13 @@ func AddServers(s *grpc.Server) *grpc.Server {

return s
}

func GetTLSCredentails() credentials.TransportCredentials {
certFile := viper.GetString("feederservice.tls.cert.file")
keyFile := viper.GetString("feederservice.tls.key.file")
creds, err := credentials.NewServerTLSFromFile(certFile, keyFile)
if err != nil {
log.Error().Msgf("Unable to read tls certificate credentails :: %s", err)
}
return creds
}

0 comments on commit ae9a1af

Please sign in to comment.