简体   繁体   English

GCP SSL 证书安装错误“证书数据无效。请确保私钥和公共证书匹配

[英]GCP SSL Certificate Installation Error "The Certificate data is invalid. Please ensure that the private key and public certificate match

I bought an SSL certificate from godaddy.com.我从godaddy.com 购买了SSL 证书。 My website is hosted on Google Cloud Portal (GCP).我的网站托管在 Google Cloud Portal (GCP) 上。 I generated the private rsa key using the methods provided on the GCP support website.我使用 GCP 支持网站上提供的方法生成了私有 rsa 密钥。

First I generated a rsa key and a CSR using the below commands首先,我使用以下命令生成了 rsa 密钥和 CSR

openssl genrsa -out example.key 2048
openssl req -new -key example.key -out example.csr

Then I copied the csr text to godaddy and generated a certificate.然后我将 csr 文本复制到 Godaddy 并生成了证书。 From the merchant site, I downloaded the certificate.我从商家网站下载了证书。 Before downloading the certificate, there was an option to select 'Server Type'.在下载证书之前,有一个选项可以选择“服务器类型”。 Following options were present:存在以下选项:

  • Apache阿帕奇
  • Exchange交换
  • IIS信息系统
  • Mac OS X Mac OS X
  • Tomcat雄猫
  • Other其他

I selected "Other" and clicked 'Download'.我选择了“其他”并单击“下载”。 A zip file was downloaded that had two files:下载了一个包含两个文件的 zip 文件:

  • ce123abc4567wxyz.crt ce123abc4567wxyz.crt
  • gd_bundle-g2-g1.crt gd_bundle-g2-g1.crt

To install the certificate, I went to GCP App Engine > Settings > SSL Certificate > Upload a new Certificate.要安装证书,我转到 GCP App Engine > 设置 > SSL 证书 > 上传新证书。 Here, I have to copy the certificate and the key.在这里,我必须复制证书和密钥。 There are two text boxes有两个文本框

  1. PEM encoded X.509 public key certificate PEM 编码的 X.509 公钥证书
  2. Unencrypted PEM encoded RSA private key未加密的 PEM 编码的 RSA 私钥

I copied the RSA private key from step-1, into the 2nd text box.我将步骤 1 中的 RSA 私钥复制到第二个文本框中。 Now the problem is that the 1st text box (where i have to enter the public key) is not accepting any of ther files present in the certificate zip folder that I downloaded from the merchant site.现在的问题是第一个文本框(我必须在其中输入公钥)不接受我从商家站点下载的证书 zip 文件夹中存在的任何文件。 I get the error我收到错误

The Certificate data is invalid.证书数据无效。 Please ensure that the private key and public certificate match请确保私钥和公共证书匹配

I tried copying either of the files to the 1st text box.我尝试将其中一个文件复制到第一个文本框。 I also copied both the file texts into the box.我还将两个文件文本复制到框中。 But nothing is working.但没有任何效果。 Please help.请帮忙。

A .crt file is probably not in .PEM format, and if not you need to convert it. .crt 文件可能不是 .PEM 格式,如果不是,则需要转换它。 See, for example, How to convert .crt to .pem例如,请参阅如何将 .crt 转换为 .pem

This was resolved.这已解决。 The certificates didn't work so I eventually regenerated the certificates.证书不起作用,所以我最终重新生成了证书。 I copied only the 'public key' part of the certificate file.我只复制了证书文件的“公钥”部分。 And made sure no spaces, no extra lines are copied.并确保没有空格,没有复制多余的行。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM