@@ -34,6 +34,7 @@ import (
3434
3535const privateKeyPathName = "nuts-private-keys"
3636const defaultPathPrefix = "kv"
37+ const vaultSecretkeyName = "key"
3738
3839// StorageType is the name of this storage type, used in health check reports and configuration.
3940const StorageType = "vaultkv"
@@ -102,8 +103,8 @@ func NewVaultKVStorage(config Config) (spi.Storage, error) {
102103 return vaultStorage , nil
103104}
104105
105- func (v vaultKVStorage ) NewPrivateKey (ctx context.Context , keyName string ) (crypto.PublicKey , string , error ) {
106- return spi .GenerateAndStore (ctx , v , keyName )
106+ func (v vaultKVStorage ) NewPrivateKey (ctx context.Context , keyPath string ) (crypto.PublicKey , string , error ) {
107+ return spi .GenerateAndStore (ctx , v , keyPath )
107108}
108109
109110func configureVaultClient (cfg Config ) (* vault.Client , error ) {
@@ -142,7 +143,7 @@ func (v vaultKVStorage) checkConnection() error {
142143
143144func (v vaultKVStorage ) GetPrivateKey (ctx context.Context , keyName string , _ string ) (crypto.Signer , error ) {
144145 path := privateKeyPath (v .config .PathPrefix , keyName )
145- value , err := v .getValue (ctx , path , keyName )
146+ value , err := v .getValue (ctx , path , vaultSecretkeyName )
146147 if err != nil {
147148 return nil , err
148149 }
@@ -181,7 +182,7 @@ func (v vaultKVStorage) storeValue(ctx context.Context, path, key string, value
181182
182183func (v vaultKVStorage ) PrivateKeyExists (ctx context.Context , keyName string , _ string ) (bool , error ) {
183184 path := privateKeyPath (v .config .PathPrefix , keyName )
184- _ , err := v .getValue (ctx , path , keyName )
185+ _ , err := v .getValue (ctx , path , vaultSecretkeyName )
185186 if errors .Is (err , spi .ErrNotFound ) {
186187 return false , nil
187188 }
@@ -224,14 +225,14 @@ func privateKeyListPath(prefix string) string {
224225 return filepath .Clean (path )
225226}
226227
227- func (v vaultKVStorage ) SavePrivateKey (ctx context.Context , keyName string , key crypto.PrivateKey ) error {
228- path := privateKeyPath (v .config .PathPrefix , keyName )
228+ func (v vaultKVStorage ) SavePrivateKey (ctx context.Context , keyPath string , key crypto.PrivateKey ) error {
229+ path := privateKeyPath (v .config .PathPrefix , keyPath )
229230 pem , err := util .PrivateKeyToPem (key )
230231 if err != nil {
231232 return fmt .Errorf ("unable to convert private key to pem format: %w" , err )
232233 }
233234
234- return v .storeValue (ctx , path , keyName , pem )
235+ return v .storeValue (ctx , path , vaultSecretkeyName , pem )
235236}
236237
237238func (v vaultKVStorage ) DeletePrivateKey (ctx context.Context , kid string ) error {
0 commit comments