Skip to content

Commit

Permalink
add ca cert
Browse files Browse the repository at this point in the history
  • Loading branch information
strokyl committed Apr 29, 2024
1 parent d06b763 commit e23fdd7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ CDK_TOKEN=<admin-token>
````
You need to define the CDK_TOKEN and CDK_BASE_URL environment variables to use this tool.
You can also use the CDK_KEY,CDK_CERT to use a certificate for tls authentication.
If you have an untrusted certificate you can use the CDK_INSECURE=true variable to disable tls verification
If you have an untrusted certificate you can use the CDK_INSECURE=true variable to disable tls verification or you can use CACERT.
Usage:
conduktor [flags]
Expand Down
9 changes: 7 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Client struct {
kinds schema.KindCatalog
}

func Make(token string, baseUrl string, debug bool, key, cert string, insecure bool) (*Client, error) {
func Make(token string, baseUrl string, debug bool, key, cert, cacert string, insecure bool) (*Client, error) {
//token is set later because it's not mandatory for getting the openapi and parsing different kind
restyClient := resty.New().SetDebug(debug).SetHeader("X-CDK-CLIENT", "CLI/"+utils.GetConduktorVersion())

Expand All @@ -34,6 +34,10 @@ func Make(token string, baseUrl string, debug bool, key, cert string, insecure b
}
}

if cacert != "" {
restyClient.SetRootCertificate(cacert)
}

result := &Client{
token: token,
baseUrl: baseUrl,
Expand Down Expand Up @@ -69,9 +73,10 @@ func MakeFromEnv() (*Client, error) {
debug := strings.ToLower(os.Getenv("CDK_DEBUG")) == "true"
key := os.Getenv("CDK_KEY")
cert := os.Getenv("CDK_CERT")
cacert := os.Getenv("CDK_CACERT")
insecure := strings.ToLower(os.Getenv("CDK_INSECURE")) == "true"

client, err := Make("", baseUrl, debug, key, cert, insecure)
client, err := Make("", baseUrl, debug, key, cert, cacert, insecure)
if err != nil {
return nil, fmt.Errorf("Cannot create client: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var rootCmd = &cobra.Command{
Use: "conduktor",
Short: "Command line tools for conduktor",
Long: `You need to define the CDK_TOKEN and CDK_BASE_URL environment variables to use this tool.
You can also use the CDK_KEY,CDK_CERT to use a certificate for tls authentication.
If you have an untrusted certificate you can use the CDK_INSECURE=true variable to disable tls verification`,
You can also use the CDK_KEY,CDK_CERT, CDK_CACERT to use a certificate for tls authentication.
If you have an untrusted certificate you can use the CDK_INSECURE=true variable to disable tls verification or set CDK_CACERT`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if *debug {
apiClient().ActivateDebug()
Expand Down

0 comments on commit e23fdd7

Please sign in to comment.