简体   繁体   English

无法让 Google Cloud Platform 识别 JSON 服务帐户密钥文件。 错误:PyOpenSSL 不可用。 建议使用 JSON,但我使用的是 JSON 密钥

[英]Can't get Google Cloud Platform to recognize JSON service account key file. Error: PyOpenSSL is not available. Suggests JSON but I'm using a JSON key

I'm an utter newbie so forgive what may be a stupid question, but when I am trying to pass the location of my service account key file using Google Cloud Platform, I am receiving the message:我是一个完全的新手所以请原谅这个愚蠢的问题,但是当我尝试使用 Google Cloud Platform 传递我的服务帐户密钥文件的位置时,我收到了消息:

WARNING: .p12 service account keys are not recomended unless it is necessary for
 backwards compatability. Please switch to a newer .json service account key for
 this account.
ERROR: (gcloud.auth.activate-service-account) PyOpenSSL is not available. If you
 have already installed PyOpenSSL, you will need to enable site packages by sett
ing the environment variable CLOUDSDK_PYTHON_SITEPACKAGES to 1. If that does not
 work, see https://developers.google.com/cloud/sdk/crypto for details or consider using .json private key instead.

However I selected and downloaded a JSON key.但是我选择并下载了一个 JSON 密钥。 Can anyone tell me what is happening and how to get around this?谁能告诉我发生了什么以及如何解决这个问题? Not sure if I'm providing enough info so please ask if you need details.不确定我是否提供了足够的信息,所以请询问您是否需要详细信息。 Thanks!谢谢!

The error indicates that you're possibly using a deprecated p12 format service account key file (as well as unable to find the required crypto libraries for reading keys in that format) instead of the json format.该错误表明您可能正在使用已弃用的p12格式服务帐户密钥文件(以及无法找到读取该格式密钥所需的加密库)而不是json格式。

You might want to double confirm that the key file you downloaded is indeed JSON.您可能需要再次确认您下载的密钥文件确实是 JSON。 A quick way to verify this is by opening this file in some text editor of if you're on *nix or OS X , you can just use cat .验证这一点的一种快速方法是在某些文本编辑器中打开此文件,如果您使用的是*nixOS X ,则可以只使用cat I've shown an example json service account key file:我展示了一个示例 json 服务帐户密钥文件:

$ cat my-service-account-key.json
{
  "type": "service_account",
  "project_id": "PROJECT_NAME",
  "private_key_id": "YOUR_PRIVATE_KEY_ID",
  "private_key": "-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n",
  "client_email": "SERVICE_ACCOUNT_NAME@PROJECT_NAME.iam.gserviceaccount.com",
  "client_id": "CLIENT_ID",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "URL",
}

To activate the service account you will have to run the gcloud auth activate-service-account command:要激活服务帐户,您必须运行gcloud auth activate-service-account命令:

gcloud auth activate-service-account --key-file=/path/to/service-account-key.json

The key must be encoded based on base64, you can do it with the following bash command:密钥必须基于 base64 编码,您可以使用以下 bash 命令进行编码:

$ cat key_file.json | base64


Please take a look at gcloud setup instructions at: https://github.com/GoogleCloudPlatform/github-actions/tree/master/setup-gcloud#inputs查看 gcloud 设置说明: https ://github.com/GoogleCloudPlatform/github-actions/tree/master/setup-gcloud#inputs

暂无
暂无

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

相关问题 如何使用 JSON 服务帐户密钥在 GO 中获取 Kubernetes 客户端集? - How can I get a Kubernetes clientset in GO using a JSON service account key? 使用发送给您的服务帐户和 JSON 密钥将数据上传到谷歌云存储 - Using a service account and JSON key which is sent to you to upload data into google cloud storage Google Cloud Platform:有没有办法使用服务帐户密钥获取有关服务帐户创建者的信息 - Google Cloud Platform: Is there a way to get information about the creator of a service account, using the service account key 哪些字段应该以 JSON 格式在 Google Cloud 服务帐户密钥中保密? - Which fields should be kept private in a Google Cloud service account key in JSON format? 如何直接从 Go 中的 GCP 服务帐户 JSON 密钥文件创建 kube.netes.Clientset? - How can I create a kubernetes.Clientset directly from a GCP service account JSON key file in Go? 寻找一种更好的方法来使用服务帐户对 Google Cloud Function 进行身份验证。 现在我将凭据 json 文件存储在后端 - Looking for a better way to authenticate Google Cloud Function with a service account. Right now I'm storing the credentials json file on the backend 安全服务帐户凭据 json 密钥 kotlin - Secure Service Account Credentials json key kotlin 错误:(gcloud.auth.activate-service-account).json 密钥文件格式无效——通过模拟服务帐户 - ERROR: (gcloud.auth.activate-service-account) The .json key file is not in a valid format -- via impersonate-service-account Google Cloud Platform 服务帐户密钥保留和客户端连接 - Google Cloud Platform Service Account Key retention and client connections 如何在 python 程序中定义我的 Google Cloud Platform 服务帐户的密钥? - How do I define my Google Cloud Platform service account's key in a python program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM