简体   繁体   English

获取公钥时出现 Google Cloud KMS 错误

[英]Google Cloud KMS error when getting public key

I'm following this Google tutorial to access my KMS public key value in Nodejs app, apparently I have an error due to missing permissions (because I can read the value from the console gcloud kms keys versions get-public-key).我正在按照这个Google 教程在 Nodejs 应用程序中访问我的 KMS 公钥值,显然由于缺少权限而出现错误(因为我可以从控制台 gcloud kms 密钥版本 get-public-key 读取值)。 The error:错误:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
    at GoogleAuth.getApplicationDefaultAsync

I created a service account with the required permissions (to read), how can I instantiate a KMS client with it?我创建了一个具有所需权限(读取)的服务帐户,如何使用它实例化 KMS 客户端? (const client = new KeyManagementServiceClient();) (const 客户端 = 新 KeyManagementServiceClient();)

Thanks谢谢

EDIT 1: I can get the key when I set an env var with the location of the SA: export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"编辑 1:当我使用 SA 的位置设置环境变量时,我可以获得密钥:export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"

How can I use the file itself (service-account-file.json) instead of env var?如何使用文件本身 (service-account-file.json) 而不是 env var?

I believe it should be as simple as我相信它应该像

const client = new KeyManagementServiceClient({
  keyFilename: '/path/to/keyfile.json'
}); 

Sorry this isn't totally clear: this isn't documented with a sample anywhere as far as I can tell, and the keyFilename property comes from three levels up the inheritance hierarchy of ClientOptions .抱歉,这并不完全清楚:据我所知,这在任何地方都没有记录,并且keyFilename属性来自ClientOptions的 inheritance 层次结构的三个层次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试 ssh 进入 Google Cloud Platform VM 时出现错误公钥 - Error Public Key when trying to ssh into Google Cloud Platform VM Python 中的双向 TLS 使用 Google Cloud KMS - Mutual TLS in Python using Google Cloud KMS 从云调度程序调用谷歌云 function 时获取权限被拒绝错误 - Getting permission denied error when calling Google cloud function from Cloud scheduler 当轮换 KMS 中的密钥时发送触发器 - Send trigger when a key in KMS is rotated 谷歌云 - 尽管接受密钥,但服务器拒绝公钥签名 - Google Cloud - Server refused public-key signature despite accepting key 如何使用玩笑模拟@google-cloud/kms - How to mock @google-cloud/kms using jest 是否可以将非对称密钥作为您自己的密钥 (BYOK) 提供给任何云提供商的云 KMS(密钥管理服务)? - Is it possible to provide asymmetric keys as your own keys (BYOK) to a cloud KMS (key management service) for any cloud providers? 当 SSL 卸载到 GCP Cloud KMS 时,如何在 NGINX 中进行解密? - How decryption is done in NGINX when SSL offloaded to GCP Cloud KMS? AWS KMS 如何确定解密时使用哪个密钥? - How AWS KMS determine which key to use when decrypt? 如何使用 Aws Kms GenerateDataKeyPair 方法生成的私钥和公钥对消息进行签名和验证 - How to use the private and public key generated from Aws Kms GenerateDataKeyPair method to sign and verify a message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM