Skip to content

Commit 2d4d9fd

Browse files
feat: use tls on port 443 (#65)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent cca032b commit 2d4d9fd

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

chains/cosmos/client/client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package client
22

33
import (
44
"context"
5+
"crypto/tls"
56
"fmt"
7+
"strings"
68
"time"
79

810
sdkmath "cosmossdk.io/math"
@@ -22,6 +24,7 @@ import (
2224
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
2325
"go.uber.org/zap"
2426
"google.golang.org/grpc"
27+
"google.golang.org/grpc/credentials"
2528
"google.golang.org/grpc/credentials/insecure"
2629

2730
"github.com/skip-mev/catalyst/chains/cosmos/types"
@@ -54,9 +57,16 @@ func NewClient(ctx context.Context, rpcAddress, grpcAddress, chainID string) (*C
5457
return nil, fmt.Errorf("failed to start rpc client: %w", err)
5558
}
5659

60+
var transportCreds credentials.TransportCredentials
61+
if strings.HasSuffix(grpcAddress, ":443") {
62+
transportCreds = credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})
63+
} else {
64+
transportCreds = insecure.NewCredentials()
65+
}
66+
5767
grpcConn, err := grpc.NewClient(
5868
grpcAddress,
59-
grpc.WithTransportCredentials(insecure.NewCredentials()),
69+
grpc.WithTransportCredentials(transportCreds),
6070
)
6171
if err != nil {
6272
return nil, fmt.Errorf("failed to create grpc connection: %w", err)

0 commit comments

Comments
 (0)