我尝试加密文件的内容并将加密的数据写入使用 Google 云 KMS 的密码文件。但是 php 脚本显示权限错误。这是我尝试过的 php 脚本
$cryptoKeyName = $kms->cryptoKeyName($projectId, $locationId, $keyRingId, $cryptoKeyId);
$plaintext = file_get_contents($plaintextFileName);
$response = $kms->encrypt($cryptoKeyName, $plaintext);
file_put_contents($ciphertextFileName, $response->getCiphertext());
我收到了这个错误
致命错误:未捕获的 Google\ApiCore\ApiException: { "message": "Permission 'cloudkms.cryptoKeyVersions.useToEncrypt' denied for resource 'projects/testproject/locations/global/keyRings/test/cryptoKeys/testkey'.", "code" : 7, "status": "PERMISSION_DENIED", "details": [] } 在第 139 行的 /home/xxxxx/xxx.com/vendor/google/gax/src/ApiException.php 中抛出
当我打印用户权限时,它显示
Role: roles/cloudkms.admin Members: user:renjith@pi-digi.com Role: roles/cloudkms.cryptoKeyEncrypterDecrypter Members: user:renjith@pi-digi.com`