KES dependency upgrade (#14454)

- Updating KES dependency to v.0.18.0
- Fixing incompatibility issue when checking for errors during KES key creation

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
Lenin Alevski
2022-03-02 23:03:40 -08:00
committed by GitHub
parent f6875bb893
commit 289fcbd08c
5 changed files with 35 additions and 161 deletions

View File

@@ -22,6 +22,7 @@ import (
"crypto/tls"
"crypto/x509"
"errors"
"net/http"
"time"
"github.com/minio/kes"
@@ -140,3 +141,10 @@ func (c *kesClient) DecryptKey(keyID string, ciphertext []byte, ctx Context) ([]
}
return c.client.Decrypt(context.Background(), keyID, ciphertext, ctxBytes)
}
// KeyExists returns if key exists on KMS based on the provided error type
func KeyExists(err error) bool {
// legacyKeyExists will be used to maintain compatibility with KES versions older than v0.18.0
legacyKeyExists := kes.NewError(http.StatusBadRequest, "key does already exist")
return errors.Is(err, kes.ErrKeyExists) || errors.Is(err, legacyKeyExists)
}