mod_ssl 配置文件位于 /etc/httpd/conf.d/ssl.conf 。要载入这个文件而使 mod_ssl 能够工作,你必须在 /etc/httpd/conf/httpd.conf 中包括 Include conf.d/*.conf 这条声明。在 Red Hat Linux 9中,该声明被默认包括在默认的 Apache HTTP 服务器 配置文件中。
如果你从 Red Hat Linux 提供的 RPM 中安装了安全服务器,一个随机钥匙和测试证书就会被生成并放置在适当的目录中。然而,在你使用安全服务器之前,你需要生成你自己的钥匙并获取正确识别你的服务器的证书。
你需要钥匙和证书才能操作安全万维网服务 — 这意味着你可以生成一个自签的证书或从某 CA 处购买一份由 CA 签名的证书。这两者间有什么区别呢?
由 CA 签名的证书为你的服务器提供两项重要能力:
浏览器(通常)会自动识别证书,并且不必提示用户就能够允许开通安全连接。
当某 CA 颁发了签名的证书,他们是在向浏览器担保提供网页的机构的身份。
如果你的安全服务器被广大公众所访问,你的安全服务器需要有 CA 签名的证书,因此访问你的网站的用户可以信任该网站的确是声明拥有它的建构所拥有。在签发证书前,CA 校验申请证书的机构确实如他们所言。
多数支持 SSL 的万维网浏览器有一个它们会自动接受证书的 CA 列表。如果浏览器遇到一份来自列表之外的授权 CA 的证书,浏览器会询问用户是否要接受连接。
你可以为你的安全服务器生成一份自签的证书,但是请留意,自签证书将不会提供和 CA 签发的证书相同的功能。自签证书将不会被用户的浏览器自动识别,而且它将不会担保提供网站的机构的身份。由 CA 签发的证书为安全服务器提供这两项重要的能力。如果你的安全服务器将会用在生产环境中,你可能会需要 CA 签发的证书。
从 CA 获取证书的手续非常简单。下面是对其步骤的简单描述:
创建加密的公钥和密钥对。
根据公钥创建证书请求。证书请求包括关于你的服务器和主持它的公司的信息。
向某 CA 发送证书请求,以及证明你的身份的文档。我们不能向你建议该选择哪个 CA。你的决定可以建立在过去的经验上,或者你的朋友或同事的经验上,或者单从经济上考虑。
当你选定了一个 CA 后,你需要遵循他们提供的说明来获取证书。
当 CA 对你的身份的真实性满意后,他们就会给你寄发一份数码证书。
在你的安全服务器上安装该证书,然后开始处理安全事务。
不论你是从 CA 处获取证书,还是使用自签的证书,第一个步骤都是生成钥匙。请参阅 第 20.6 节 来获取生成钥匙的指示。
20.6. 生成钥匙
你必须是根用户才能生成钥匙。
首先, cd 到 /etc/httpd/conf 目录中,使用下面的命令删除在安装中生成的假钥匙和证书:
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [GB]: US State or Province Name (full name) [Berkshire]: North Carolina Locality Name (eg, city) [Newbury]: Raleigh Organization Name (eg, company) [My Company Ltd]: Test Company Organizational Unit Name (eg, section) []: Testing Common Name (your name or server's hostname) []: test.example.com Email Address []: admin@example.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [GB]: US State or Province Name (full name) [Berkshire]: North Carolina Locality Name (eg, city) [Newbury]: Raleigh Organization Name (eg, company) [My Company Ltd]: My Company, Inc. Organizational Unit Name (eg, section) []: Documentation Common Name (your name or server's hostname) []: myhost.example.com Email Address []: myemail@example.com