Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TLS props in config feature #179

Merged
merged 1 commit into from
Apr 20, 2022
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
53 changes: 53 additions & 0 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ var (
envKeys = []string{
FlagNamespace,
FlagAddress,
FlagTLSCertPath,
FlagTLSKeyPath,
FlagTLSCaPath,
FlagTLSDisableHostVerification,
FlagTLSServerName,
}
keys = append(rootKeys, envKeys...)
)
Expand All @@ -66,6 +71,30 @@ func newConfigCommands() []*cli.Command {
Name: FlagAddress,
Usage: "Print Temporal address (for active environment)",
},
&cli.StringFlag{
Name: FlagTLSCertPath,
Value: "",
Usage: "Print path to x509 certificate",
},
&cli.StringFlag{
Name: FlagTLSKeyPath,
Value: "",
Usage: "Print path to private key",
},
&cli.StringFlag{
Name: FlagTLSCaPath,
Value: "",
Usage: "Print path to server CA certificate",
},
&cli.BoolFlag{
Name: FlagTLSDisableHostVerification,
Usage: "Print whether tls host name verification is disabled",
},
&cli.StringFlag{
Name: FlagTLSServerName,
Value: "",
Usage: "Print target TLS server name",
},
},
Action: func(c *cli.Context) error {
return GetValue(c)
Expand Down Expand Up @@ -97,6 +126,30 @@ func newConfigCommands() []*cli.Command {
Usage: "host:port for Temporal frontend service",
Value: localHostPort,
},
&cli.StringFlag{
Name: FlagTLSCertPath,
Value: "",
Usage: "Path to x509 certificate",
},
&cli.StringFlag{
Name: FlagTLSKeyPath,
Value: "",
Usage: "Path to private key",
},
&cli.StringFlag{
Name: FlagTLSCaPath,
Value: "",
Usage: "Path to server CA certificate",
},
&cli.BoolFlag{
Name: FlagTLSDisableHostVerification,
Usage: "Disable tls host name verification (tls must be enabled)",
},
&cli.StringFlag{
Name: FlagTLSServerName,
Value: "",
Usage: "Override for target server name",
},
},
Action: func(c *cli.Context) error {
return SetValue(c)
Expand Down
17 changes: 12 additions & 5 deletions cli/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"io"
"net"
"net/http"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -171,11 +173,16 @@ func (b *clientFactory) createGRPCConnection(c *cli.Context) (*grpc.ClientConn,
}

func (b *clientFactory) createTLSConfig(c *cli.Context) (*tls.Config, error) {
certPath := c.String(FlagTLSCertPath)
keyPath := c.String(FlagTLSKeyPath)
caPath := c.String(FlagTLSCaPath)
disableHostNameVerification := c.Bool(FlagTLSDisableHostVerification)
serverName := c.String(FlagTLSServerName)
certPath := readFlagOrConfig(c, FlagTLSCertPath)
keyPath := readFlagOrConfig(c, FlagTLSKeyPath)
caPath := readFlagOrConfig(c, FlagTLSCaPath)
disableHostNameVerificationS := readFlagOrConfig(c, FlagTLSDisableHostVerification)
disableHostNameVerification, err := strconv.ParseBool(disableHostNameVerificationS)
if err != nil {
return nil, fmt.Errorf("unable to read TLS disable host verification flag: %s", err)
}

serverName := readFlagOrConfig(c, FlagTLSServerName)

var host string
var cert *tls.Certificate
Expand Down