Skip to content

Commit

Permalink
add support for truststore #178
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Mar 30, 2023
1 parent cae66a1 commit 6005131
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cmd/targetservers/crtts.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ var CreateCmd = &cobra.Command{
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = targetservers.Create(name, description, host, port, enable, grpc, keyStore, keyAlias, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
_, err = targetservers.Create(name, description, host, port, enable, grpc, keyStore, keyAlias, trustStore, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
return

},
}

var description, host, keyStore, keyAlias, sslinfo, enable string
var description, host, keyStore, keyAlias, trustStore, sslinfo, enable string
var grpc, tlsenabled, clientAuthEnabled, ignoreValidationErrors bool
var port int

Expand All @@ -67,6 +67,8 @@ func init() {
"", "Key store for the target server; must be used with sslinfo")
CreateCmd.Flags().StringVarP(&keyAlias, "keyAlias", "",
"", "Key alias for the target server; must be used with sslinfo")
CreateCmd.Flags().StringVarP(&trustStore, "trustStore", "",
"", "Trust store for the target server; must be used with sslinfo")
CreateCmd.Flags().StringVarP(&sslinfo, "sslinfo", "",
"", "Enable SSL Info on the target server")
CreateCmd.Flags().BoolVarP(&tlsenabled, "tls", "",
Expand Down
4 changes: 3 additions & 1 deletion cmd/targetservers/updatets.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var UpdateCmd = &cobra.Command{
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = targetservers.Update(name, description, host, port, enable, grpc, keyStore, keyAlias, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
_, err = targetservers.Update(name, description, host, port, enable, grpc, keyStore, keyAlias, trustStore, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
return
},
}
Expand All @@ -67,6 +67,8 @@ func init() {
"", "Key store for the target server; must be used with sslinfo")
UpdateCmd.Flags().StringVarP(&keyAlias, "keyAlias", "",
"", "Key alias for the target server; must be used with sslinfo")
UpdateCmd.Flags().StringVarP(&trustStore, "trustStore", "",
"", "Trust store for the target server; must be used with sslinfo")
UpdateCmd.Flags().StringVarP(&sslinfo, "sslinfo", "",
"", "Enable SSL Info on the target server")
UpdateCmd.Flags().BoolVarP(&tlsenabled, "tls", "",
Expand Down
11 changes: 6 additions & 5 deletions internal/client/targetservers/targetservers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ type commonName struct {
}

// Create
func Create(name string, description string, host string, port int, enable string, grpc bool, keyStore string, keyAlias string, sslinfo string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
func Create(name string, description string, host string, port int, enable string, grpc bool, keyStore string, keyAlias string, trustStore string, sslinfo string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
targetsvr := targetserver{
Name: name,
}

return createOrUpdate("create", targetsvr, name, description, host, port, enable, grpc, keyStore, keyAlias, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
return createOrUpdate("create", targetsvr, name, description, host, port, enable, grpc, keyStore, keyAlias, trustStore, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
}

// Update
func Update(name string, description string, host string, port int, enable string, grpc bool, keyStore string, keyAlias string, sslinfo string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
func Update(name string, description string, host string, port int, enable string, grpc bool, keyStore string, keyAlias string, trustStore string, sslinfo string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
apiclient.SetPrintOutput(false)
targetRespBody, err := Get(name)
if err != nil {
Expand All @@ -82,10 +82,10 @@ func Update(name string, description string, host string, port int, enable strin
if err = json.Unmarshal(targetRespBody, &targetsvr); err != nil {
return nil, err
}
return createOrUpdate("update", targetsvr, name, description, host, port, enable, grpc, keyStore, keyAlias, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
return createOrUpdate("update", targetsvr, name, description, host, port, enable, grpc, keyStore, keyAlias, trustStore, sslinfo, tlsenabled, clientAuthEnabled, ignoreValidationErrors)
}

func createOrUpdate(action string, targetsvr targetserver, name string, description string, host string, port int, enable string, grpc bool, keyStore string, keyAlias string, sslinfo string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
func createOrUpdate(action string, targetsvr targetserver, name string, description string, host string, port int, enable string, grpc bool, keyStore string, keyAlias string, trustStore string, sslinfo string, tlsenabled bool, clientAuthEnabled bool, ignoreValidationErrors bool) (respBody []byte, err error) {
targetsvr.Description = description
targetsvr.Host = host
targetsvr.IsEnabled, _ = strconv.ParseBool(enable)
Expand All @@ -103,6 +103,7 @@ func createOrUpdate(action string, targetsvr targetserver, name string, descript
IgnoreValidationErrors: ignoreValidationErrors,
Keyalias: keyAlias,
Keystore: keyStore,
Truststore: trustStore,
}
}

Expand Down

0 comments on commit 6005131

Please sign in to comment.