首页 > 解决方案 > 使用 Cloud Deployment Manager 上传 SSL 证书

问题描述

我不断尝试,但没有运气。以下是我每次尝试时收到的消息

The fingerprint of the deployment is j6t0HcwFHHQifZteb2l3aA==
Waiting for update [operation-1553685800030-58511aa341085-accaf31f-b8a2d802]...failed.
ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation [operation-1553685800030-58511aa341085-accaf31f-b8a2d802]: errors:
- code: RESOURCE_ERROR
  location: /deployments/infrastructure/resources/lb-ssl-certificate
  message: '{"ResourceType":"compute.v1.sslCertificate","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"errors":[{"domain":"global","message":"The
    SSL certificate could not be parsed.","reason":"sslCertificateCouldNotParseCert"}],"message":"The
    SSL certificate could not be parsed.","statusMessage":"Bad Request","requestPath":"https://www.googleapis.com/compute/v1/projects/xxx/global/sslCertificates","httpMethod":"POST"}}'

下面是我的 jinja 片段 (sslcert-template.jinja)

- name: lb-ssl-certificate
  type: compute.v1.sslCertificate
  properties:
    certificate: example.com.crt
    privateKey: example.com.key

请注意example.com.crtexample.com.key与sslcert-template.jinja位于同一位置。我正在使用 docker google/cloud-sdk 来执行此操作。我使用具有项目所有者角色的电子邮件登录

我还尝试了带有证书和密钥的 gcloud,效果很好

gcloud compute ssl-certificates create sample --certificate=example.com.crt --private-key=example.com.key
Created [https://www.googleapis.com/compute/v1/projects/xxx/global/sslCertificates/sample].
NAME    CREATION_TIMESTAMP
sample  2019-03-29T20:59:14.371-07:00

经过一些尝试..我尝试在python模板中进行操作,并将实际的证书和密钥作为值定义为多行并且它只是工作

标签: google-cloud-platform

解决方案


发布答案,因为这是截至 2020 年 6 月 Google 中deployment manager ssl certificates的热门话题,即使在结果列表的下方有答案(但不在 stackoverflow 上)。

部署管理器希望文件内联在 yaml 文件中,而不是作为本地文件的路径。

即,它应该看起来像这样:

- name: ssl-cert
  type: compute.v1.sslCertificate
  properties:
    certificate: |
      -----BEGIN CERTIFICATE-----
      MIIFazCCA1OgAwIBAgIUUVkDsK2nWJtToHzFjukeJzPyKaYwDQYJKoZIhvcNAQEL
      BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
      ...
      eDbQMIjIXvZNP6e3D3COn862l+OA/MjWjFVZnaraCpKByc1SBBaD1axQ/MY0jks=
      -----END CERTIFICATE-----
    privateKey: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIJpDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIgqbfXwjdaNICAggA
      MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECCKSeDnJWXINBIIJUHZOCaP6RbbM
      ...
      bru0DNVNlF4pMWzX6QaInsAPJoA63kS+
      -----END RSA PRIVATE KEY-----

我不确定是否有办法自动将文本文件内联到 jinja 模板中。


推荐阅读