3.1. 保护互联网协议

3.1.1. 在 Apache 中使用 mod_ssl 证书

首先,永远不要将自签名根 CA 证书用于任何应用程序,尤其是 Apache,因为它要求您删除私钥上的密码。

首先,生成并签署一个证书请求,并将通用名称 (CN) 设置为 www.mysite.com。删除任何额外的信息,只保留 ---CERTIFICATE--- 部分。

密钥需要设置为不安全,因此在读取私钥时不需要密码。 使用包含私钥的 newreq.pem 文件,并从中删除密码。

openssl rsa -in newreq.pem -out wwwkeyunsecure.pem

由于密钥(私钥)是不安全的,您必须清楚自己在做什么:检查文件权限等... 如果有人得到了它,您的站点就会受到威胁(已警告您)。现在您可以使用 newcert 和 cakeyunsecure.pem 用于 Apache。

将 wwwkeyunsecure.pem 和 newcert.pem 复制到 /etc/httpd/conf/ssl/ 目录中,分别命名为 wwwkeyunsecure.pem 和 wwwcert.crt。

编辑 /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 
----

停止并启动 httpd (/etc/rc.d/init.d/httpd stop) 确保所有进程都已终止 (killall httpd) 并启动 httpd (/etc/rc.d/init.d/httpd start)

3.1.2. 在 IMAPS 中使用证书

请阅读“在 POPS 中使用证书”一节,以获取更多信息。

3.1.3. 在 POPS 中使用证书

通过生成证书、解除私钥保护并将两者组合到 /etc/ssl/imap/ipop3sd.pem 中,可以为 ipop3sd 创建 pem 文件。 这是 Mandrake 9.0 上的 imap rpm 期望找到该文件的位置。 类似的过程可用于 imap,并将文件放在 /etc/ssl/imap/imapsd.pem 中。

CN 应该是邮件客户端连接到的名称(例如 mail.xyz.org)。 在 MS-Outlook 中,在“服务器”选项卡上,为传入邮件服务器输入 mail.xyz.org,并在“高级”选项卡上选中“此服务器需要安全连接 (SSL)”,这将将连接端口更改为 995 (imaps)。 必须在 MS Internet Explorer 中安装受信任的根 CA,才能验证来自 mail.xyz.org 的证书。

3.1.4. 在 Postfix 中使用证书

待修复

3.1.5. 在 Stunnel 中使用证书

待修复

3.1.6. 使用 Microsoft 密钥管理器生成和签署密钥

在 Microsoft 密钥管理器中,选择要为其创建密钥的服务,例如 IMAP(或 WWW)。 使用向导生成新密钥。 确保专有名称与以前生成的密钥不相同,例如,对于通用名称 (CN),请使用 imap.mycompany.com。 向导会将请求放在文件 C:\NewKeyRq.txt 中。 密钥管理器会显示带有删除线的密钥,表示该密钥未签名。

将此文件导入到 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 导出到运行密钥管理器的计算机,并在密钥管理器应用程序中选择密钥图标时,右键单击并单击“安装密钥证书”,选择此文件,输入密码。 现在密钥已完全可以使用。