Windows xp 安裝 Apache with HTTPS (SSL)

reference
http://blog.changyy.org/2009/05/windows-apache-with-https-ssl-windows-xp.html

建立憑證


openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
openssl rsa -in server.key -out server.key

以 Windows XP 為例,預設的 Apache HTTP Server 2.2.11 安裝目錄是 "C:\Program Files\Apache Software Foundation\Apache2.2",以該目錄為基準,簡寫為 "~\Apache2.2"


所謂的 openssl 是在 "~\Apache2.2\bin\openssl.exe"

上述部份指令執行時會說找不到 config 檔案,config 檔是在 "~\Apache2.2\conf\openssl.cnf" ,請多加參數 -config "~\Apache2.2\conf\openssl.cnf"

切換到 "~\Apache2.2" 去執行上述指令,如 cmd mode 下執行
bin\openssl genrsa -des3 -out server.key 4096 
碰到要增加 config 則用 
-config conf\openssl.cnf 囉

建立 server.key 時記得輸入一下密碼,該密碼後面還會詢問到。

簡單的詢問範例,"()"內不用打,是簡單的敘述註解
Country Name (2 letter code) [AU]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:YunLin Country (城市)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:CYY(組織,例如公司)
Organizational Unit Name (eg, section) []:CYY (單位,例如公司部門等)
Common Name (eg, YOUR name) []:localhost (主機的全名)
Email Address []:cyy@localhost (信箱)

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:(可按Enter即可)
An optional company name []:(可按Enter即可)
設定 Apache httpd.conf


將上述產生的 server.key 跟 server.crt ,就直接擺到 "~\Apache2.2\conf" 即可(預設的憑證用的檔名跟位置)

設定 httpd.conf

打開 LoadModule ssl_module modules/mod_ssl.so 註解
打開 Include conf/extra/httpd-ssl.conf
基本上重新啟動 Apache 即可搞定囉!

將錯誤訊息修成 sec_error_ca_cert_invalid ,新增成例外網站
最後,有任何問題請多看看 ~\Apache2.2\logs\error.log 或 ~\Apache2.2\logs\access.log ,這幫助很大的!

留言

這個網誌中的熱門文章

網路筆記 File Upload on PHP Server in Android

LA流浪記

杜拜