使用 OpenSSL 签证中心为 IIS 做伺服器签证

当您使用 Apache 要做 SSL 凭证时,可以完全使用 OpenSSL 去做完整的设定,这个设定我在 更安全的的连线 Apache + SSL (new window) 有讨论其实做,在此就不再赘言,但如果要让 IIS 也做到有 SSL 的连线,就需要做一点工夫了。

要让 IIS 做 CA 凭证不难,但是要为该凭证做签证到是有点麻烦,你可以使用 MS 的凭证中心来做这件事情,但如果你的单位已经有 Linux Based 凭证中心,那么也可以直接使用。

建立专有凭证中心的私有金钥

你很有可能已经有签证中心,也有了该签证中心的签证档,如果真的是如此的话,就可以跳过此一步骤,否则请依下所示来建立一个凭证中心的私有金钥。请注意,你也可以使用 更安全的的连线 Apache + SSL (new window) 中已经生产出金钥。

0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
root # openssl genrsa -des3 -out ca.l-penguin.idv.tw.key 1024
Generating RSA private key, 1024 bit long modulus
............................................++++++
.............++++++
e is 65537 (0x10001)
Enter pass phrase for ca.l-penguin.idv.tw.key: your_password
Verifying - Enter pass phrase for ca.l-penguin.idv.tw.key: your_password
root # ls<
ca.l-penguin.idv.tw.key
root #
保护私钥

做好凭证之后,理应只有 root 或有权限的人可以读取这个凭证。

0001
0002
root # chmod 400 ca.l-penguin.idv.tw.key
建立凭证中心的签证档

请使用刚刚生产的私有金钥做一个签证档。

0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
root # openssl req -new -key ca.l-penguin.idv.tw.key -x509 -days 1095 -out ca.l-penguin.idv.tw.crt
Enter pass phrase for ca.l-penguin.idv.tw.key: your_passowrd
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]:TW
State or Province Name (full name) [Berkshire]:Taipei
Locality Name (eg, city) [Newbury]:Taipei
Organization Name (eg, company) [My Company Ltd]:l-penguin Corp.
Organizational Unit Name (eg, section) []:CA
Common Name (eg, your name or your server's hostname) []:ca.l-penguin.idv.tw
Email Address []:steven@l-penguin.idv.tw
相同的道理,我们也需要保护这个签证。
0001
root # chmod 400 ca.l-penguin.idv.tw.crt
广 告
现在我要为 IIS 服务 web.l-penguin.idv.tw 设定一个 SSL 连线。在 IIS 网站内容里,选择目录安全设定页签,点选伺服器凭证。请依下顺序建立一个 web.l-penguin.idv.tw 的私有金钥。

设定私钥之后,请把它上传到你的认证主机。

接下来使用 ca.l-penguin.idv.tw 去做 web.l-penguin.idv.tw 的签证。

0001
0002
0003
0004
0005
0006
root # openssl x509 -req -days 365 -in web.l-penguin.idv.tw.csr -CA ca.l-penguin.idv.tw.crt -CAkey ca.l-penguin.idv.tw.key -CAcreateserial -out web.l-penguin.idv.tw.crt
Signature ok
subject=/CN=web.l-penguin.idv.tw/OU=Web/O=l-penguin Corp./L=Taipei/ST=Taiwan/C=TW
Getting CA Private Key
Enter pass phrase for ca.l-penguin.idv.tw.key:your_password
root #
当你做好签证之后,请把它保存好。接下来要让 IIS 使用这个签证。

现在就可以让 IIS 以 https 的 SSL 通道做资料传送。

02/18/2007


首页