ssl - 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.
错误的原因是什么?如何解决?
解决方案
gcloud compute ssl-certificates create mysertificatee \
--certificate mySite.com.csr \
--private-key mySite.com.key
的参数--certificate
应该是证书,即mySite.com.pem
. 相反,mySite.com.csr
给出了 CSR。
推荐阅读
- python - 根据输入张量的形状在可签名函数内创建张量
- angular - 如何使用Angular Material Datepicker禁用星期几
- vba - 跳过未选中的复选框并将标题复制到工作表上
- python - np.array 未传递具有相同第一维 = 值错误的数组
- python-3.x - 致命的 Python 错误:initfsencoding: 无法加载文件系统编解码器 ModuleNotFoundError: No module named 'encodings' visual studio code
- javascript - 如果在字符串中找到超链接,则只允许特定域
- css - 有没有办法删除这个自定义字体的字体粗细?
- python - 使用 ruamel.yaml 在 yaml 文件的第一行添加了不希望的缩进和破折号
- r - 根据名称数据库通过名称的部分匹配和重命名来汇总行
- python - 双摆RK4