Skip to content

Commit

Permalink
Default seal type to Shamir on older seal configs (#5956)
Browse files Browse the repository at this point in the history
  • Loading branch information
briankassouf authored Dec 14, 2018
1 parent dd459e0 commit 70084e2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions vault/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 70084e2

Please sign in to comment.