Skip to content
Open
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
5 changes: 5 additions & 0 deletions cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func NewCliApp() *cli.App {
Usage: "Authorization header to set for gRPC requests",
EnvVars: []string{"TEMPORAL_CLI_AUTH"},
},
&cli.BoolFlag{
Name: FlagEnableTLS,
Usage: "Enable TLS",
EnvVars: []string{"TEMPORAL_CLI_TLS"},
},
&cli.StringFlag{
Name: FlagTLSCertPath,
Value: "",
Expand Down
16 changes: 16 additions & 0 deletions cli/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,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(FlagEnableTLS)
enableTLS, err := strconv.ParseBool(enableTLSS)
if err != nil {
return nil, fmt.Errorf("unable to read TLS flag: %w", err)
}

serverName := c.String(FlagTLSServerName)

Expand Down Expand Up @@ -256,6 +261,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(FlagAddress)
if hostPort == "" {
hostPort = 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 cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var (
FlagJobID = "job-id"
FlagYes = "yes"
FlagYesAlias = []string{"y"}
FlagEnableTLS = "tls"
FlagTLSCertPath = "tls-cert-path"
FlagTLSKeyPath = "tls-key-path"
FlagTLSCaPath = "tls-ca-path"
Expand Down
5 changes: 5 additions & 0 deletions cli_curr/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func NewCliApp() *cli.App {
Name: FlagAutoConfirm,
Usage: "Automatically confirm all prompts",
},
cli.BoolFlag{
Name: FlagEnableTLS,
Usage: "Enable TLS",
EnvVar: "TEMPORAL_CLI_TLS",
},
cli.StringFlag{
Name: FlagTLSCertPath,
Value: "",
Expand Down
12 changes: 12 additions & 0 deletions cli_curr/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func (b *clientFactory) createTLSConfig(c *cli.Context) (*tls.Config, error) {
caPath := c.GlobalString(FlagTLSCaPath)
disableHostNameVerification := c.GlobalBool(FlagTLSDisableHostVerification)
serverName := c.GlobalString(FlagTLSServerName)
enableTLS := c.GlobalBool(FlagEnableTLS)

var host string
var cert *tls.Certificate
Expand Down Expand Up @@ -233,6 +234,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.GlobalString(FlagAddress)
if hostPort == "" {
hostPort = 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