Repository: cadence-workflow/cadence (language: go)

Issue:
Add TLS ServerName as CLI option for Cadence Cassandra Tool
**Is your feature request related to a problem? Please describe.**
TLS support has been added for Cassandra by this request #2681. Then, followed by another PR (#3066) to add ServerName to TLS config. However, this option is missing in cadence-cassandra-tool. That's why I received the error message:

```sh
error: failed to connect to <ip address> due to error: x509: cannot validate certificate for <ip address> because it doesn't contain any IP SANs
no connections were made when creating the session
```

**Proposed Solution**
1. Add ServerName as CLI option for cadence-cassandra-tool
2. Pass the ServerName to the [cql client TLS config](https://github.com/uber/cadence/blob/master/tools/cassandra/handler.go#L192-L198)

**Additional context**
N/A


Discussion / hints:

Fix patch:
diff --git a/tools/cassandra/handler.go b/tools/cassandra/handler.go
index 9b69011d56f..776042bcdc3 100644
--- a/tools/cassandra/handler.go
+++ b/tools/cassandra/handler.go
@@ -195,6 +195,7 @@ func newCQLClientConfig(cli *cli.Context) (*CQLClientConfig, error) {
 			KeyFile:                cli.GlobalString(schema.CLIFlagTLSKeyFile),
 			CaFile:                 cli.GlobalString(schema.CLIFlagTLSCaFile),
 			EnableHostVerification: cli.GlobalBool(schema.CLIFlagTLSEnableHostVerification),
+			ServerName:             cli.GlobalString(schema.CLIFlagTLSServerName),
 		}
 	}
 
diff --git a/tools/cassandra/main.go b/tools/cassandra/main.go
index 24d8c0114f0..97561cb5d0b 100644
--- a/tools/cassandra/main.go
+++ b/tools/cassandra/main.go
@@ -144,6 +144,11 @@ func BuildCLIOptions() *cli.App {
 			Usage:  "TLS host verification",
 			EnvVar: "CASSANDRA_TLS_VERIFY_HOST",
 		},
+		cli.StringFlag{
+			Name:   schema.CLIFlagTLSServerName,
+			Usage:  "TLS ServerName",
+			EnvVar: "CASSANDRA_TLS_SERVER_NAME",
+		},
 	}
 
 	app.Commands = []cli.Command{
diff --git a/tools/common/schema/types.go b/tools/common/schema/types.go
index 0eb9dab6f15..0ccaae710c0 100644
--- a/tools/common/schema/types.go
+++ b/tools/common/schema/types.go
@@ -168,6 +168,9 @@ const (
 	CLIFlagTLSCaFile = "tls-ca-file"
 	// CLIFlagTLSEnableHostVerification enables tls host verification (tls must be enabled)
 	CLIFlagTLSEnableHostVerification = "tls-enable-host-verification"
+	// CLIFlagTLSServerName is the Server Name Indication to verify the hostname on the returned certificates.
+	// It is also included in the client's handshake to support virtual hosting unless it is an IP address.
+	CLIFlagTLSServerName = "tls-server-name"
 )
 
 var rmspaceRegex = regexp.MustCompile(`\s+`)


Test patch: