ssl - GCE 上的自签名 SSL 证书—— 'SSL certificate could not be parsed'

标签 ssl google-cloud-platform openssl google-compute-engine

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

enter image description here

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

我遵循了 openSSL sign https_client certificate with CA 上的命令并按顺序成功运行以下命令:

// 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. 

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

最佳答案

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

--certificate 的参数应该是证书,即 mySite.com.pem。取而代之的是 CSR mySite.com.csr

关于ssl - GCE 上的自签名 SSL 证书—— 'SSL certificate could not be parsed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52918836/

相关文章:

PHP + curl + TLS 1.2

java - 使用 JSSE 时应该如何进行主机名验证?

ruby - Sinatra + HTTPS 重定向到 HTTP?

google-cloud-platform - 有没有办法逐步部署 Cloud Functions 并在出现问题时自动回滚?

google-cloud-platform - 在 secret 更新时更新 Cloud Run 实例

python - 为什么 Python md5 在 FIPS 模式下可用?

c - OpenSSL ASN.1 编程教程

sql-server - 从 exe 到 SQL 的安全连接

c++ - 在 Windows x64 上设置 openssl 时找不到 libeay32.lib 和 ssleay32.lib 文件

mongodb - 将 MongoDB 部署到 Google Cloud Platform 的最佳方式?