系統規格:
win 2000 server SP4、 apache_2.2.8-win32-x86-openssl-0.9.8g.msi (2008-01-19 release)
(1)在windows系統中,apache的安裝版(Win32 Binary)可分為有包括openssl及no-ssl-module的兩種版本,記得下載有openssl module的。下載完並著手安裝並沒有特別困難的部分只要跟著對話框完成安裝即可。安裝完直接在瀏覽器上鍵入http://127.0.0.1,如果出現It works!就表示安裝完成。
(2)由於並沒有向認證中心申請CA(Certficate Authority) 所以這次的安裝是以實作「自發CA認證」為主,而我們所下載的msi安裝檔是搭配openssl 0.9.8g。所以接著我們要編輯%APACHE_HOME%\conf\httpd.conf
去掉
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
前面的"#"並將httpd.conf存檔
(3)接著我們就要來產生CA認證的檔案了,首先你得到網路上搜尋並且下載openssl.cnf 這個檔案回來,並且放到%APACHE_HOME%\bin的目錄底下,windows系統會將他辨認為speeddial,所以連點兩下並沒有辦法進行編輯而必需用記事本或editplus等文字編輯器以"開啟舊檔"的方式開啟,開啟後請更改以下設定
dir = ssl
certs = $dir\\certs # Where the issued certs are kept
crl_dir = $dir\\crl # Where the issued crl are kept
database = $dir\\index.txt # database index file.
new_certs_dir = $dir\\newcerts # default place for new certs.
certificate = $dir\\cacert.pem # The CA certificate
serial = $dir\\serial # The current serial number
crl = $dir\\crl.pem # The current CRL
private_key = $dir\\privkey.pem # The private key //原本有private資料夾
RANDFILE = $dir\\private.rnd # private random number file //原本有private資料夾
//其實就是多加個反斜線上去
並且將x509_extensions = x509v3_extensions 那一行前面加個"#"
(4)接著在%APACHE_HOME%\bin的目錄底下建立ssl資料夾也就是產生%APACHE_HOME%\bin\ssl目錄,並且在這個目錄中新建立二個檔案與一個資料夾
1. 新增一個文字檔,名稱為index.txt,內容為空白
2. 新增一個檔案,名稱為serial(不要副檔名),內容輸入01
3. 新增資料夾,名稱為newcerts
(5)接著就是重頭戲來了,到command line模式底下,切換目錄到%APACHE_HOME%\bin,開始鍵入指令產生CA憑證
>openssl genrsa -des3 -out ssl/ca.key 1024 //Enter pass phrase for ssl/ca.key and verify again
>openssl req -config openssl.cnf -new -key ssl/ca.key -out ssl/ca.csr //Enter pass phrase for ssl/ca.key and insert information about your certificate request.
>openssl x509 -days 3650 -req -signkey ssl/ca.key -in ssl/ca.csr -out ssl/ca.crt //Enter pass phrase for ssl/ca.key.
>openSSL genrsa -out ssl/server.key 1024
>openssl req -config openssl.cnf -new -key ssl/server.key -out ssl/server.csr //Enter pass phrase for ssl/ca.key and insert information about your certificate request.
>openssl ca -config openssl.cnf -days 3650 -cert ssl/ca.crt -keyfile ssl/ca.key -in ssl/server.csr -out ssl/server.crt //Enter pass phrase for ssl/ca.key and Check the request signature
(6)完成CA設定後,%APACHE_HOME%\bin\ssl下有11個檔案及一個目錄,再將整個ssl目錄copy到%APACHE_HOME%\conf下
(7)修改%APACHE_HOME%\conf\extra\httpd-ssl.conf
SSLCertificateFile %APACHE_HOME%/conf/ssl/server.crt //指到新建的server.crt憑證
SSLCertificateKeyFile %APACHE_HOME%/conf/ssl/server.key
(8)此時重新啟動Apache server並鍵入https://127.0.0.1,就應該大功告成了。
參考資料:
http://blog.roodo.com/myroodo/archives/4219557.html
tips:
- %APACHE_HOME%即指你安裝apache的地方。
- %APACHE_HOME%\conf\extra\httpd-ssl.conf的<VirtualHost _default_:443>開頭,這一大段是記錄SSL的設定組態
沒有留言:
張貼留言