Skip to content

Commit

Permalink
[FAB-1755] Replace orderer GRPC Server
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1755

This sets the stage for enabling TLS for the
orderer by replacing the direct use of the grpc
pacakge for creating a server with the use of
the GRPC server from the core/comm package

* use comm.GRPCServer in main.go
* add TLS config struct to localconfig
* add config paramters to orderer.yaml

Fixes FAB-1755

Change-Id: Icba2776c1e503021b2873c149949b2b3b0c686fa
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Jan 19, 2017
1 parent 7e52b66 commit 14f1aea
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
11 changes: 11 additions & 0 deletions orderer/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,23 @@ type General struct {
MaxWindowSize uint32
ListenAddress string
ListenPort uint16
TLS TLS
GenesisMethod string
GenesisFile string
Profile Profile
LogLevel string
}

//TLS contains config used to configure TLS for the grpc server
type TLS struct {
Enabled bool
ServerKey string
ServerCertificate string
ServerRootCAs []string
ClientAuthEnabled bool
ClientRootCAs []string
}

// Genesis contains config which is used by the provisional bootstrapper
type Genesis struct {
OrdererType string
Expand Down
18 changes: 13 additions & 5 deletions orderer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"

"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/core/comm"
"github.com/hyperledger/fabric/orderer/common/bootstrap/file"
"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
"github.com/hyperledger/fabric/orderer/kafka"
Expand All @@ -41,7 +42,6 @@ import (

"github.com/Shopify/sarama"
logging "github.com/op/go-logging"
"google.golang.org/grpc"
)

var logger = logging.MustGetLogger("orderer/main")
Expand All @@ -59,14 +59,22 @@ func main() {
}()
}

grpcServer := grpc.NewServer()

lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", conf.General.ListenAddress, conf.General.ListenPort))
if err != nil {
fmt.Println("Failed to listen:", err)
return
}

//Create GRPC server - return if an error occurs
secureConfig := comm.SecureServerConfig{
UseTLS: conf.General.TLS.Enabled,
}
grpcServer, err := comm.NewGRPCServerFromListener(lis, secureConfig)
if err != nil {
fmt.Println("Failed to return new GRPC server: ", err)
return
}

var lf ordererledger.Factory
switch conf.General.LedgerType {
case "file":
Expand Down Expand Up @@ -135,7 +143,7 @@ func main() {
int(conf.General.MaxWindowSize),
)

ab.RegisterAtomicBroadcastServer(grpcServer, server)
ab.RegisterAtomicBroadcastServer(grpcServer.Server(), server)
logger.Infof("Beginning to serve requests")
grpcServer.Serve(lis)
grpcServer.Start()
}
10 changes: 10 additions & 0 deletions orderer/orderer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ General:
# Listen port: The port on which to bind to listen
ListenPort: 7050

# TLS: TLS settings for the GRPC server
TLS:
Enabled: false
ServerKey:
ServerCertificate:
ServerRootCAs:
ClientAuthEnabled: false
ClientRootCAs:


# Log Level: The level at which to log. This accepts logging specifications
# per fabric/docs/Setup/logging-control.md
LogLevel: info
Expand Down

0 comments on commit 14f1aea

Please sign in to comment.