Skip to content

Commit 0059b2d

Browse files
committed
feat(cli): Add global flag --skip-tls-verify
Signed-off-by: spbsoluble <1661003+spbsoluble@users.noreply.github.com>
1 parent b3e18af commit 0059b2d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

cmd/helpers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,19 @@ func outputError(err error, isFatal bool, format string) {
333333
}
334334

335335
func outputResult(result interface{}, format string) {
336+
log.Debug().
337+
Interface("result", result).
338+
Str("format", format).
339+
Msg(fmt.Sprintf("%s outputResult", DebugFuncEnter))
336340
if format == "json" {
337341
fmt.Println(result)
338342
} else {
339343
fmt.Println(fmt.Sprintf("%s", result))
340344
}
345+
log.Debug().
346+
Interface("result", result).
347+
Str("format", format).
348+
Msg(fmt.Sprintf("%s outputResult", DebugFuncExit))
341349
}
342350

343351
func readCSVHeader(filename string) ([]string, error) {

cmd/root.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var (
4040
noPrompt bool
4141
expEnabled bool
4242
debugFlag bool
43+
skipVerifyFlag bool
4344
kfcUsername string
4445
kfcHostName string
4546
kfcPassword string
@@ -112,6 +113,10 @@ func getServerConfigFromFile(configFile string, profile string) (*auth_providers
112113
return nil, fmt.Errorf("invalid profile: %s", profile)
113114
}
114115

116+
if skipVerifyFlag {
117+
serverConfig.SkipTLSVerify = true
118+
}
119+
115120
log.Debug().Msg("return: getServerConfigFromFile()")
116121
return &serverConfig, nil
117122
}
@@ -137,7 +142,9 @@ func getServerConfigFromEnv() (*auth_providers.Server, error) {
137142
isBasicAuth := uOk && pOk
138143
isOAuth := cOk && csOk && tOk
139144

140-
if svOk {
145+
if skipVerifyFlag {
146+
skipVerifyBool = true
147+
} else if svOk {
141148
//convert to bool
142149
skipVerify = strings.ToLower(skipVerify)
143150
skipVerifyBool = skipVerify == "true" || skipVerify == "1" || skipVerify == "yes" || skipVerify == "y" || skipVerify == "t"
@@ -533,6 +540,8 @@ func initClient(saveConfig bool) (*api.Client, error) {
533540
Str("providerProfile", providerProfile).
534541
Bool("noPrompt", noPrompt).
535542
Bool("saveConfig", saveConfig).
543+
Bool("logInsecure", logInsecure).
544+
Bool("skipVerifyFlag", skipVerifyFlag).
536545
Str("hostname", kfcHostName).
537546
Str("username", kfcUsername).
538547
Str("password", hashSecretValue(kfcPassword)).
@@ -753,6 +762,10 @@ func init() {
753762
"Will not attempt to connect to GitHub for latest release information and resources.",
754763
)
755764
RootCmd.PersistentFlags().BoolVar(&debugFlag, "debug", false, "Enable debugFlag logging.")
765+
RootCmd.PersistentFlags().BoolVar(
766+
&skipVerifyFlag, "skip-tls-verify", false,
767+
"Disable TLS verification for API requests to Keyfactor Command.",
768+
)
756769
//RootCmd.PersistentFlags().BoolVar(
757770
// &logInsecure,
758771
// "log-insecure",

cmd/stores.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ var storesListCmd = &cobra.Command{
7474
log.Error().Err(jErr).Send()
7575
return jErr
7676
}
77+
7778
outputResult(output, outputFormat)
7879
return nil
7980
},

0 commit comments

Comments
 (0)