windows下Apache配置SSL安全連線

來源:互聯網
上載者:User

標籤:blog   http   io   檔案   資料   for   ar   div   

什麼是SSL?

SSL(Secure Socket Layer): 是為Http傳輸提供安全的協議,通過認證認證來確保用戶端和網站伺服器之間的資料是安全。Open SSL:http://www.openssl.org/source/


一、下載並安裝 支援SSL的 Apache
  
1.安裝配有SSL模組的apache,

http://httpd.apache.org/download.cgi#apache23
附件提供httpd-2.2.15-win32-x86-openssl-0.9.8m-r2.msi

2.配置:開啟Apache的設定檔conf/httpd.conf

  • LoadModule ssl_module modules/mod_ssl.so 
  • Include conf/extra/httpd-ssl.conf

去掉兩行前面的#,自訂的設定檔.conf還可以通過include包含進來。


修改httpd-ssl.conf(或者自訂的*-ssl.conf) 檔案裡的兩個欄位:

  • SSLCertificateFile "D:/Apache2.2/conf/server.crt"
  • SSLCertificateKeyFile "D:/Apache2.2/conf/server.key"



二、為網站伺服器產生認證及私密金鑰檔案
       
1. 產生伺服器Apache的一個RSA私密金鑰

openssl genrsa -out server.key 1024

 



 

產生了一個1024位元組的檔案server.key,產生認證簽署請求CSR

2. 產生簽署申請

openssl req -new –out server.csr -key server.key -config ..\conf\openssl.cnf 
    


 

其中,     

  •  Country Name:兩個字母的國家代號
  •  State or Province Name:省份名稱
  •  Locality Name:城市名稱
  •  Organization Name:公司名稱
  •  Organizational Unit Name:部門名稱
  •  Common Name:你的姓名
  •  Email Address:地址


此時產生簽署檔案server.csr.

三、通過CA為網站伺服器簽署認證
      
1.Generating RSA private key for CA (1024 bit) [ca.key]
產生CA私密金鑰

openssl genrsa  -out ca.key 1024 

 


 

多出ca.key檔案

2.Generating X.509 certificate signing request for CA [ca.csr]
利用CA的私密金鑰產生CA的自簽署認證

openssl req  -new -x509 -days 365 -key ca.key -out ca.crt  -config ..\conf\openssl.cnf 

 



 

3.CA為網站伺服器簽署認證

在bin目錄下建立demoCA,裡面建立以下檔案,index.txt,serial:serial內容為01,其他為空白,以及檔案夾 newcert.再執行一遍,即可產生server.crt檔案

openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config ..\conf\openssl.cnf

 



 

四、然後將  server.crt,server.key複製到apache的conf檔案夾下,重啟Apache。

  • httpd-2.2.15-win32-x86-openssl-0.9.8m-r2.rar (5.1 MB)
  • 下載次數: 162

原文:http://suky.iteye.com/blog/713687

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.