Skip to content

Commit c60d859

Browse files
author
Jason Yellick
committed
[FAB-5319] peer cli orderer TLS hostname override
The peer CLI supports TLS communication with the orderer. It does this by specifying a -caCert command line flag which specifies the orderer's TLS CA cert file. However, for certainly deployments such as k8s, it is not always possible to have the hostname on the TLS cert correctly match the hostname used to connect to the orderer. The peer config supports setting the hostname via peer.tls.rootcert.file and peer.tls.serverhostoverride config variables. However, because the peer channel commands initialize TLS without the use of these variables, this CR does not attempt to re-use this logic, and instead adds a new flag. The new flag has the name -ordererTLSHostnameOverride Change-Id: I9cc5ac59803daf633de7e20813905aca53b99a37 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent d9c3202 commit c60d859

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

peer/channel/channel.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ var (
5555
genesisBlockPath string
5656

5757
// create related variables
58-
chainID string
59-
channelTxFile string
60-
orderingEndpoint string
61-
tls bool
62-
caFile string
63-
timeout int
58+
chainID string
59+
channelTxFile string
60+
orderingEndpoint string
61+
tls bool
62+
caFile string
63+
ordererTLSHostnameOverride string
64+
timeout int
6465
)
6566

6667
// Cmd returns the cobra command for Node
@@ -83,6 +84,7 @@ func AddFlags(cmd *cobra.Command) {
8384
flags.StringVarP(&orderingEndpoint, "orderer", "o", "", "Ordering service endpoint")
8485
flags.BoolVarP(&tls, "tls", "", false, "Use TLS when communicating with the orderer endpoint")
8586
flags.StringVarP(&caFile, "cafile", "", "", "Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint")
87+
flags.StringVarP(&ordererTLSHostnameOverride, "ordererTLSHostnameOverride", "", "", "The hostname override to use when validating the TLS connection to the orderer.")
8688
}
8789

8890
var flags *pflag.FlagSet
@@ -162,7 +164,7 @@ func InitCmdFactory(isEndorserRequired EndorserRequirement, isOrdererRequired Or
162164
// check for TLS
163165
if tls {
164166
if caFile != "" {
165-
creds, err := credentials.NewClientTLSFromFile(caFile, "")
167+
creds, err := credentials.NewClientTLSFromFile(caFile, ordererTLSHostnameOverride)
166168
if err != nil {
167169
return nil, fmt.Errorf("Error connecting to %s due to %s", orderingEndpoint, err)
168170
}

0 commit comments

Comments
 (0)