Skip to content

Commit

Permalink
Credhub parses the ca key of certificate types
Browse files Browse the repository at this point in the history
It can therefore now also return more than one cert from a single get,
which should help with some things to come.
  • Loading branch information
thomasmitchell committed Jun 19, 2020
1 parent de7d7b5 commit 0838956
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions storage/configserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,24 @@ func (v *ConfigServerAccessor) Get(path string) (map[string]string, error) {
return nil, err
}

if cred.Type == "certificate" {
if certInterface, found := cred.Value.(map[string]interface{})["certificate"]; found && certInterface != nil {
var keysToCheck []string
switch cred.Type {
case "certificate":
keysToCheck = []string{"certificate", "ca"}
}

ret := map[string]string{}

for _, key := range keysToCheck {
if certInterface, found := cred.Value.(map[string]interface{})[key]; found && certInterface != nil {
certAsString, isString := certInterface.(string)
if isString {
return map[string]string{"certificate": certAsString}, nil
ret[key] = certAsString
}
}
}

return nil, nil
return ret, nil
}

func (v *ConfigServerAccessor) Authenticate(last interface{}) (
Expand Down

0 comments on commit 0838956

Please sign in to comment.