Skip to content

Commit

Permalink
grpcdao secure (#4525)
Browse files Browse the repository at this point in the history
Co-authored-by: dustinxie <[email protected]>
  • Loading branch information
envestcc and dustinxie authored Dec 20, 2024
1 parent 991f160 commit e53ef04
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion blockchain/blockdao/grpcblockdao.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package blockdao

import (
"context"
"crypto/tls"
"encoding/hex"
"fmt"
"sync/atomic"
Expand All @@ -15,6 +16,7 @@ import (
"github.com/iotexproject/iotex-proto/golang/iotextypes"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/types/known/emptypb"

Expand Down Expand Up @@ -57,8 +59,10 @@ func (gbd *GrpcBlockDAO) Start(ctx context.Context) error {
opts := []grpc.DialOption{}
if gbd.insecure {
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{MinVersion: tls.VersionTLS12})))
}
gbd.conn, err = grpc.Dial(gbd.url, opts...)
gbd.conn, err = grpc.NewClient(gbd.url, opts...)
if err != nil {
return err
}
Expand Down

0 comments on commit e53ef04

Please sign in to comment.