File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package main
22
33import (
44 "context"
5+ "crypto/tls"
56 "fmt"
67 "net/http"
78 _ "net/http/pprof" // nolint:gosec
@@ -12,6 +13,7 @@ import (
1213 "github.com/spf13/cobra"
1314 "github.com/uptrace/bun"
1415 "google.golang.org/grpc"
16+ "google.golang.org/grpc/credentials"
1517 "google.golang.org/grpc/credentials/insecure"
1618
1719 "github.com/oasisprotocol/oasis-core/go/common"
@@ -194,7 +196,16 @@ func runRoot() error {
194196
195197 // Establish a gRPC connection with the client node.
196198 logger .Info ("connecting to local node" , "addr" , cfg .NodeAddress )
197- conn , err := cmnGrpc .Dial (cfg .NodeAddress , grpc .WithTransportCredentials (insecure .NewCredentials ()))
199+ var dialOpts []grpc.DialOption
200+ switch cmnGrpc .IsLocalAddress (cfg .NodeAddress ) {
201+ case true :
202+ // No TLS for local connections.
203+ dialOpts = append (dialOpts , grpc .WithTransportCredentials (insecure .NewCredentials ()))
204+ case false :
205+ creds := credentials .NewTLS (& tls.Config {MinVersion : tls .VersionTLS12 })
206+ dialOpts = append (dialOpts , grpc .WithTransportCredentials (creds ))
207+ }
208+ conn , err := cmnGrpc .Dial (cfg .NodeAddress , dialOpts ... )
198209 if err != nil {
199210 logger .Error ("failed to establish connection" , "err" , err )
200211 return err
You can’t perform that action at this time.
0 commit comments