Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ func (b *clientFactory) createTLSConfig(c *cli.Context) (*tls.Config, error) {
if err != nil {
return nil, fmt.Errorf("unable to read TLS disable host verification flag: %w", err)
}
enableTLSS := c.String(common.FlagTLS)
enableTLS, err := strconv.ParseBool(enableTLSS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason to do custom parsing? (instead of c.Bool(..))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing custom parsing to keep consistency with your code above:

disableHostNameVerificationS := c.String(common.FlagTLSDisableHostVerification)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so these values are accepted with strconv.ParseBool, true: "1", "t", "T", "true", "TRUE", "True", false: "0", "f", "F", "false", "FALSE", "False"

I'd go with the c.Bool for consistency with the rest of the CLI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

if err != nil {
return nil, fmt.Errorf("unable to read TLS flag: %w", err)
}

serverName := c.String(common.FlagTLSServerName)

Expand Down Expand Up @@ -267,6 +272,17 @@ func (b *clientFactory) createTLSConfig(c *cli.Context) (*tls.Config, error) {
tlsConfig := auth.NewTLSConfigForServer(host, !disableHostNameVerification)
return tlsConfig, nil
}
// If we are given a TLS flag, set the TLS server name from the address
if enableTLS {
hostPort := c.String(common.FlagAddress)
if hostPort == "" {
hostPort = common.LocalHostPort
}
// Ignoring error as we'll fail to dial anyway, and that will produce a meaningful error
host, _, _ = net.SplitHostPort(hostPort)
tlsConfig := auth.NewTLSConfigForServer(host, !disableHostNameVerification)
return tlsConfig, nil
}

return nil, nil
}
Expand Down
1 change: 1 addition & 0 deletions common/defs-flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (
FlagAddrDefinition = "The host and port (formatted as host:port) for the Temporal Frontend Service."
FlagNSAliasDefinition = "Identifies a Namespace in the Temporal Workflow."
FlagMetadataDefinition = "Contains gRPC metadata to send with requests (formatted as key=value)."
FlagTLSDefinition = "Enable TLS encryption without additional options such as mTLS or client certificates"
FlagTLSCertPathDefinition = "Path to x509 certificate."
FlagTLSKeyPathDefinition = "Path to private certificate key."
FlagTLSCaPathDefinition = "Path to server CA certificate."
Expand Down
7 changes: 7 additions & 0 deletions common/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ var (
FlagTaskQueueAlias = []string{"t"}
FlagTaskQueueType = "task-queue-type"
FlagTimeZone = "time-zone"
FlagTLS = "tls"
FlagTLSCaPath = "tls-ca-path"
FlagTLSCertPath = "tls-cert-path"
FlagTLSDisableHostVerification = "tls-disable-host-verification"
Expand Down Expand Up @@ -161,6 +162,12 @@ var SharedFlags = []cli.Flag{
Usage: FlagMetadataDefinition,
Category: CategoryGlobal,
},
&cli.BoolFlag{
Name: FlagTLS,
Usage: FlagTLSDefinition,
EnvVars: []string{"TEMPORAL_CLI_TLS"},
Category: CategoryGlobal,
},
&cli.StringFlag{
Name: FlagTLSCertPath,
Value: "",
Expand Down