首页 > 解决方案 > GCE 上的自签名 SSL 证书——“无法解析 SSL 证书”

问题描述

我有一个网站,比如说mySite.com在 Debian 虚拟机 Google Cloud Engine 上运行。我希望在这个站点上安装 SSL 证书,这样 Firefox 就不会在登录字段上显示安全错误(不太熟悉网络安全——请原谅天真的措辞)

在此处输入图像描述

我知道 SSL 应该由中央机构 (CA) 签署,为此,我可以 i.) 付费并由已知 CA 签署,或 ii.) 自己创建一个 CA 并签署我自己的证书而无需支付任何事物。我现在正在尝试第二种选择,首先看看 GCE 上的情况如何,以及它是否足以满足我的目的——也就是说,自我认证的 SSL 将提供 GCE 上的安全性。

我按照openSSL 使用 CA 签署 https_client 证书上的命令并按顺序成功运行以下命令:

// Generate CA key and cert:
openssl genrsa -out msite.CA.key 2048
openssl req -x509 -new -key msite.CA.key -days 3650 -out msite.CA.pem -subj '/C=AA/ST=aa/L=aaa/O=msite/OU=msite/CN=aa/emailAddress=sth'

// Generate client key and csr:
openssl genrsa -out mySite.com.key 2048
openssl req -new -key mySite.com.key -out mySite.com.csr -subj '/C=BB/ST=bb/L=bb/O=msite/OU=msite/CN=bb/emailAddress=bbb'

// Generate client cert signed with CA cert:
openssl x509 -req -days 365 -CA msite.CA.pem -CAkey msite.CA.key -CAcreateserial -CAserial serial -in mySite.com.csr -out mySite.com.pem

// verify:
openssl verify -verbose -CAfile msite.CA.pem mySite.com.pem
// the output to this is “mySite.com.pem: OK”

到目前为止一切似乎都很好——所有上述命令都运行没有任何错误。此时,我运行了以下命令(来自https://cloud.google.com/load-balancing/docs/ssl-certificates的命令)

gcloud compute ssl-certificates create mysertificatee \
--certificate mySite.com.csr \
--private-key mySite.com.key

并得到错误:

ERROR: (gcloud.compute.ssl-certificates.create) Some requests did not succeed: 
- The SSL certificate could not be parsed. 

错误的原因是什么?如何解决?

标签: sslgoogle-cloud-platformopensslgoogle-compute-engine

解决方案


gcloud compute ssl-certificates create mysertificatee \
--certificate mySite.com.csr \
--private-key mySite.com.key

的参数--certificate应该是证书,即mySite.com.pem. 相反,mySite.com.csr给出了 CSR。


推荐阅读