From 8c2c9705d9acc2ff962389312b39f28da4fdcaaa Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Wed, 20 Jun 2018 14:33:02 -0700 Subject: [PATCH] connect/ca: use weak type decoding in the Vault config parsing --- agent/connect/ca/provider_vault.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/agent/connect/ca/provider_vault.go b/agent/connect/ca/provider_vault.go index d2099eabcf..8eaf945657 100644 --- a/agent/connect/ca/provider_vault.go +++ b/agent/connect/ca/provider_vault.go @@ -285,7 +285,18 @@ func (v *VaultProvider) Cleanup() error { func ParseVaultCAConfig(raw map[string]interface{}) (*structs.VaultCAProviderConfig, error) { var config structs.VaultCAProviderConfig - if err := mapstructure.Decode(raw, &config); err != nil { + decodeConf := &mapstructure.DecoderConfig{ + ErrorUnused: true, + Result: &config, + WeaklyTypedInput: true, + } + + decoder, err := mapstructure.NewDecoder(decodeConf) + if err != nil { + return nil, err + } + + if err := decoder.Decode(raw); err != nil { return nil, fmt.Errorf("error decoding config: %s", err) }