首先,永远不要将自签名根 CA 证书用于任何应用程序,尤其是 Apache,因为它要求您删除私钥上的密码。
首先,生成并签署一个证书请求,并将通用名称 (CN) 设置为 www.mysite.com。删除任何额外的信息,只保留 ---CERTIFICATE--- 部分。
密钥需要设置为不安全,因此在读取私钥时不需要密码。 使用包含私钥的 newreq.pem 文件,并从中删除密码。
openssl rsa -in newreq.pem -out wwwkeyunsecure.pem |
编辑 /etc/httpd/conf/ssl/ssl.default-vhost.conf。
---- # Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A test # certificate can be generated with `make certificate' under # built time. #SSLCertificateFile conf/ssl/ca.crt SSLCertificateFile wwwcert.crt # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. #SSLCertificateKeyFile conf/ssl/ca.key.unsecure SSLCertificateKeyFile wwwkeyunsecure.pem ---- |
将此文件导入到 OpenSSL /var/ssl 目录中,将其重命名为 newreq.pem,并像往常一样签署该请求。
CA.pl -sign |
文件 newcert.pem 还不适合密钥管理器,因为它包含一些文本和 -CERTIFICATE- 部分。 我们必须删除文本,最简单的方法是执行
openssl x509 -in newcert.pem -out newcertx509.pem |
使用文本编辑器也适合删除 -CERTIFICATE- 部分之外的所有内容。
newcertx509.pem 文件现在只包含 -CERTIFICATE- 部分。
将文件 newcertx509.pem 导出到运行密钥管理器的计算机,并在密钥管理器应用程序中选择密钥图标时,右键单击并单击“安装密钥证书”,选择此文件,输入密码。 现在密钥已完全可以使用。