mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-10 00:27:02 +02:00
* Adding Transit Autoseal * adding tests * adding more tests * updating seal info * send a value to test and set current key id * updating message * cleanup * Adding tls config, addressing some feedback * adding tls testing * renaming config fields for tls
35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package seal
|
|
|
|
import (
|
|
"github.com/hashicorp/errwrap"
|
|
log "github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/vault/command/server"
|
|
"github.com/hashicorp/vault/logical"
|
|
"github.com/hashicorp/vault/vault"
|
|
"github.com/hashicorp/vault/vault/seal/transit"
|
|
)
|
|
|
|
func configureTransitSeal(config *server.Config, infoKeys *[]string, info *map[string]string, logger log.Logger, inseal vault.Seal) (vault.Seal, error) {
|
|
transitSeal := transit.NewSeal(logger)
|
|
sealInfo, err := transitSeal.SetConfig(config.Seal.Config)
|
|
if err != nil {
|
|
// If the error is any other than logical.KeyNotFoundError, return the error
|
|
if !errwrap.ContainsType(err, new(logical.KeyNotFoundError)) {
|
|
return nil, err
|
|
}
|
|
}
|
|
autoseal := vault.NewAutoSeal(transitSeal)
|
|
if sealInfo != nil {
|
|
*infoKeys = append(*infoKeys, "Seal Type", "Transit Address", "Transit Mount Path", "Transit Key Name")
|
|
(*info)["Seal Type"] = config.Seal.Type
|
|
(*info)["Transit Address"] = sealInfo["address"]
|
|
(*info)["Transit Mount Path"] = sealInfo["mount_path"]
|
|
(*info)["Transit Key Name"] = sealInfo["key_name"]
|
|
if namespace, ok := sealInfo["namespace"]; ok {
|
|
*infoKeys = append(*infoKeys, "Transit Namespace")
|
|
(*info)["Transit Namespace"] = namespace
|
|
}
|
|
}
|
|
return autoseal, nil
|
|
}
|