Default seal type to Shamir on older seal configs (#5956)
This commit is contained in:
parent
d9d47bb252
commit
75e25711a0
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
"github.com/hashicorp/vault/shamir"
|
||||
"github.com/hashicorp/vault/vault/seal"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1640,6 +1641,15 @@ func (c *Core) PhysicalSealConfigs(ctx context.Context) (*SealConfig, *SealConfi
|
|||
if err := jsonutil.DecodeJSON(pe.Value, barrierConf); err != nil {
|
||||
return nil, nil, errwrap.Wrapf("failed to decode barrier seal configuration at migration check time: {{err}}", err)
|
||||
}
|
||||
err = barrierConf.Validate()
|
||||
if err != nil {
|
||||
return nil, nil, errwrap.Wrapf("failed to validate barrier seal configuration at migration check time: {{err}}", err)
|
||||
}
|
||||
// In older versions of vault the default seal would not store a type. This
|
||||
// is here to offer backwards compatability for older seal configs.
|
||||
if barrierConf.Type == "" {
|
||||
barrierConf.Type = seal.Shamir
|
||||
}
|
||||
|
||||
var recoveryConf *SealConfig
|
||||
pe, err = c.physical.Get(ctx, recoverySealConfigPlaintextPath)
|
||||
|
@ -1651,6 +1661,15 @@ func (c *Core) PhysicalSealConfigs(ctx context.Context) (*SealConfig, *SealConfi
|
|||
if err := jsonutil.DecodeJSON(pe.Value, recoveryConf); err != nil {
|
||||
return nil, nil, errwrap.Wrapf("failed to decode seal configuration at migration check time: {{err}}", err)
|
||||
}
|
||||
err = recoveryConf.Validate()
|
||||
if err != nil {
|
||||
return nil, nil, errwrap.Wrapf("failed to validate seal configuration at migration check time: {{err}}", err)
|
||||
}
|
||||
// In older versions of vault the default seal would not store a type. This
|
||||
// is here to offer backwards compatability for older seal configs.
|
||||
if recoveryConf.Type == "" {
|
||||
recoveryConf.Type = seal.Shamir
|
||||
}
|
||||
}
|
||||
|
||||
return barrierConf, recoveryConf, nil
|
||||
|
|
Loading…
Reference in New Issue