admin 發表於 2018-2-9 20:27:00

Apache 2.2.17 設定OpenSSL 加密(windows)

一、首先必須已經安裝了Apache,接著進行下面步驟

1.首先切換到Apache的bin目錄
 這裡的apache的目錄在D:\Program Files (x86)\Apache Software Foundation\Apache2.2\

2.使用OpenSSL建立『server.key』私鑰檔案,並輸入自訂短密碼
openssl genrsa -des3 -out server.key 2048

3.使用私鑰去建立『server.csr』憑證請求檔
openssl req -new -key server.key -out server.csr -config ..\conf\openssl.cnf

4.在建立憑證請求檔時會詢問相關資訊
Country Name (2 letter code) :所在國家簡寫
State or Province Name (full name) :所在國家
Locality Name (eg, city) []:所在城市
Organization Name (eg, company) :公司名稱
Organizational Unit Name (eg, section) []:組織名稱
Common Name (e.g. server FQDN or YOUR name) []:網址名稱
Email Address []:聯絡人信箱

5.使用憑證請求檔及私鑰檔去建立3650天的X.509格式憑證的CRT憑證檔
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

6.以上步驟完成後會得到共三個檔案『server.key』、『server.csr』、『server.crt』請將三個檔案移到『\conf』目錄下。

7.打開『httpd.conf』檔案找到以下兩句並取消註解

LoadModule ssl_module modules/mod_ssl.so
Include ./conf/extra/httpd-ssl.conf<<這裡是ssl設定檔的位置>>

8.打開ssl設定檔,
#SSLSessionCache "shmcb:d:/Program Files (x86)\Apache Software Foundation\Apache2.2\logs\ssl_scache(512000)"

9.開啟瀏覽器進入『https://localhost/』測試是否成功

二、可能遇到的問題
由於windows不支援加密解密所以在log會看到

SSLPassPhraseDialog builtin is not supported on Win32................

解決方式:
1、複製 server.key 為 server.key.org
2、對 server.key.org 解密 openssl rsa -in server.key.org -out server.key 輸入密碼解密成功
3、打開 httpd-ssl.conf 找到 SSLPassPhraseDialog builtin 在前面加上#

頁: [1]
查看完整版本: Apache 2.2.17 設定OpenSSL 加密(windows)