一、簡介
The Apache HTTP Server module mod_ssl provides an interface to the OpenSSL library, which provides Strong Encryption using the Secure Sockets Layer and Transport Layer Security protocols.
二、資源
• 作業環境:Windows Server 2008 Enterprise 32bits
• 名稱及版本:Apache v2.2.17
• SSL 類型: Self-Signed SSL
• 參考資訊:Securing Your Apache 2 Server with SSL
• 參考設定檔:C:\Apache2.2\conf\extra\httpd-ssl.conf
三、前置準備工作
• 請先確認安裝的 Apache 是否內含 OpenSSL (可檢查 Apache 安裝路徑的 bin 資料夾下 , 如:C:\Apache2.2\bin 下是否有openssl.exe 檔)(2011/2/22 修正 : 後來發現 Apache 2.2.17 內含的 OpenSSL v0.9.8o 好像有一些問題 , 請參考 : Apache 2.2.17 內含的 OpenSSL v0.9.8o 有問題 , 所以就算 Apache 2.2.17 已內含 OpenSSL v0.9.8o , 還是要先安裝及設定 OpenSSL)
• 如果沒有則先安裝及設定 OpenSSL
四、安裝及設定
4.1 使用 Apache 內含的 OpenSSL v0.9.8o
4.1.1 Create a Local Key Pair , 開啟 MS-DOS 視窗 , 切換路徑到 C:\Apache2.2\bin
執行:openssl genrsa -des3 -out wsuc.tw.key 1024 , 其中 wsuc.tw 是我的 Domain Name , wsuc.tw.key 檔會產生在 C:\Apache2.2\bin資料夾下
去除 [pass phrase] , 先把 wsuc.tw.key 改名為 wsuc.tw.key.org , 然後執行:openssl rsa –in wsuc.tw.key.org –out wsuc.tw.key
4.1.2 Creating a Self-Signed Certificate , 執行:openssl req -new -key wsuc.tw.key -x509 -out svr01.crt , 其中 wsuc.tw.key 是前一步驟產生的 key 檔 , svr01 是 Server 的 Hostname
輸入憑證相關資訊 , 如:Country Name=TW , State Name=Taiwan , Organization Name=wsuc , Common Name=svr01.wsuc.tw (Hostname) , 其他可以不用填
4.2 使用新安裝的 OpenSSL v1.0.0c
4.2.1 Create a Local Key Pair , 開啟 MS-DOS 視窗 , 切換路徑到 C:\OpenSSL-Win32\bin
執行:openssl genrsa -des3 -out wsuc.tw.key 1024 , 其中 wsuc.tw 是我的 Domain Name , wsuc.tw.key 檔會產生在 C:\OpenSSL-Win32\bin 資料夾下
去除 [pass phrase] , 先把 wsuc.tw.key 改名為 wsuc.tw.key.org , 然後執行:openssl rsa –in wsuc.tw.key.org –out wsuc.tw.key
4.2.2 Creating a Self-Signed Certificate , 執行:openssl req -new -key wsuc.tw.key -x509 -out svr01.crt , 其中 wsuc.tw.key 是前一步驟產生的 key 檔 , svr01 是 Server 的 Hostname
輸入憑證相關資訊 , 如:Country Name=TW , State Name=Taiwan , Organization Name=wsuc , Common Name=svr01.wsuc.tw (Hostname) , 其他可以不用填
4.3 在 Apache 安裝路徑下建一個 [ssl] 資料夾 , 然後從 C:\Apache2.2\bin 或C:\OpenSSL-Win32\bin 資料夾複製 wsuc.tw.key 及 svr01.crt 到 C:\Apache2.2\ssl 資料夾下
4.4 編輯 C:\Apache2.2\conf 資料夾下的 httpd.conf , 加入 [Listen 443]
4.5 移除 # , 打開 LoadModule ssl_module modules/mod_ssl.so 這行設定
4.6 從 C:\Apache2.2\conf\extra\httpd-ssl.conf 檔中複製下列設定到 C:\Apache2.2\conf 檔中
1: ##
2: ## SSL Global Context
3: ##
4: AddType application/x-x509-ca-cert .crt
5: AddType application/x-pkcs7-crl .crl
6: SSLSessionCache "shmcb:C:/Apache2.2/logs/ssl_scache(512000)"
7: SSLSessionCacheTimeout 300
8: SSLMutex default
加入 SSL Global Context
4.7 從 C:\Apache2.2\conf\extra\httpd-ssl.conf 檔中複製下列設定到 C:\Apache2.2\conf 檔中 , 並做適當的修改
1: <VirtualHost _default_:443>
2:
3: DocumentRoot "C:/Apache2.2/htdocs"
4: ServerName svr01.wsuc.tw:443
5: ServerAdmin jameschiang@sysage.com.tw
6: ErrorLog "C:/Apache2.2/logs/error.log"
7: TransferLog "C:/Apache2.2/logs/access.log"
8: SSLEngine on
9: SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
10: SSLCertificateFile "C:/Apache2.2/ssl/svr01.crt"
11: SSLCertificateKeyFile "C:/Apache2.2/ssl/wsuc.tw.key"
12: <FilesMatch "\.(cgi|shtml|phtml|php)$">
13: SSLOptions +StdEnvVars
14: </FilesMatch>
15: <Directory "C:/Apache2.2/cgi-bin">
16: SSLOptions +StdEnvVars
17: </Directory>
18: BrowserMatch ".*MSIE.*" \
19: nokeepalive ssl-unclean-shutdown \
20: downgrade-1.0 force-response-1.0
21: CustomLog "C:/Apache2.2/logs/ssl_request.log" \
22: "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
23:
24: </VirtualHost>
在 httpd.conf 檔中加入 <VirtualHost _default_:443> 設定
修改後 , 儲存 [httpd.conf] 檔並重新啟動 Apache 服務
4.8 測試 SSL , 開啟 FireFox 瀏覽器 , 連接 [https://svr01.wsuc.tw] , 點按 [我了解此安全風險]
點按 [新增例外網站]
點按 [確認安全例外]
使用 FireFox 測試 SSL 成功 !
4.9 測試 SSL , 開啟 IE 瀏覽器 , 連接 [https://svr01.wsuc.tw] , 點按 [繼續瀏覽此網站]
使用 IE 測試 SSL 成功 !
留言列表