Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 897

Apache Web Server/Resin Server設置https通訊的步驟

$
0
0

當我們的網站使用https通訊協定時,網站主機必須安裝安全性憑證,將網頁傳輸的資料做SSL(Secure Sockets Layer)加密,以防止傳輸內容遭有心人攔截讀取。不透過第三方認證中心而建立自製https憑證檔有兩個步驟要執行:

  1. 主機建立SSL需要的憑證檔案
  2. 瀏覽器端安裝憑證

Apache Web Server設定憑證環境

以下使用Apache Web Server 2.0為例。安裝好Apache Web Server後以下列指令產生server.crt與server.key:

  1. 到Apache Web Server的bin目錄產生CA的RSA私鑰server.key:
openssl genrsa -out server.key 1024

2.利用CA私鑰產生簽署憑證:

**openssl req -new -x509 -days 365 -key server.key -out server.crt -config ..\conf\openssl.cnf**
Loading 'screen' into random state - done
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:tw
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taipei
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany
Organizational Unit Name (eg, section) []:IT-Dept
Common Name (e.g. server FQDN or YOUR name) []:ssl.mycompany.com.tw
Email Address []:

3.配置http.conf與SSL.conf

<VirtualHost *:80>
       ServerAdmin  電子郵件信箱,可任意填,但不能為空值
       DocumentRoot  網站根目錄
       ServerName 網站domain,需與前面的CommonName內容相同
       ErrorLog logs/error_log
       CustomLog logs/access_log common
       #SSLEngine on
       SSLCertificateFile server.crt的完整路徑
       SSLCertificateKeyFile server.key的完整路徑
   </VirtualHost>

命令行啟動測試:

apache.exe -D SSL

Resin安裝SSL憑證

Resin 3支援兩種SSL憑證,一種是標準的OpenSSL憑證,另一種是簡易的JSSE憑證。 以下使用 OpenSSL安裝說明。

  1. Server.crt與Server.key的產生方式與Apache Web Server相同
  2. 將server.crt與server.key複製到Resin系統目錄裡
  3. 編輯resin.conf或resin.xml
<http port="443">
  <openssl>
    <certificate-key-file>server.key</certificate-key-file>
    <certificate-file>server.crt</certificate-file>        
    <password>your_password</password>
    <protocol>-sslv3</protocol>
  </openssl>
</http>

##

您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 897

Trending Articles