Преглед на файлове

Validate that the signer can get the public key.

Mariano Cano преди 5 години
родител
ревизия
cae08bff80
променени са 1 файла, в които са добавени 11 реда и са изтрити 0 реда
  1. 11 0
      kms/cloudkms/cloudkms.go

+ 11 - 0
kms/cloudkms/cloudkms.go

@@ -141,6 +141,17 @@ func (k *CloudKMS) CreateSigner(req *apiv1.CreateSignerRequest) (crypto.Signer,
 		return nil, errors.New("signing key cannot be empty")
 	}
 
+	// Validate that the key exists
+	ctx, cancel := defaultContext()
+	defer cancel()
+
+	_, err := k.client.GetPublicKey(ctx, &kmspb.GetPublicKeyRequest{
+		Name: req.SigningKey,
+	})
+	if err != nil {
+		return nil, errors.Wrap(err, "cloudKMS GetPublicKey failed")
+	}
+
 	return NewSigner(k.client, req.SigningKey), nil
 }