差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:apache_ssl [2008/08/20 16:58] jonathantech:apache_ssl [2009/11/02 14:03] (目前版本) jonathan
行 1: 行 1:
 +====== Apache 設定雙向 SSL 認證方式 ======
 +  * 需要自己產生免費 Server 憑證,請參考 **[[tech:openssl_caserver]]**。
 +  * 將產生的 ServerCA.crt, ServerCA.key, RootCA.crt 放入 /etc/pki/tls/certs/ 內 <code sh>
 +cp ServerCA.crt /etc/pki/tls/certs/
 +cp ServerCA.key /etc/pki/tls/certs/
 +cp RootCA.crt /etc/pki/tls/certs/
 +cd /etc/pki/tls/certs/
 +chmod og-rwx ServerCA.crt
 +chmod og-rwx ServerCA.key
 +chmod og-rwx RootCA.crt
 +</code>
 +===== - 設定 Apache 內的 ssl.conf =====
 +<code sh>
 +vi /etc/httpd/conf.d/ssl.conf
 +</code>
 +<file>
 +:
 +LoadModule ssl_module modules/mod_ssl.so
 +:
 +SSLMutex default
 +:
 +SSLCertificateFile /etc/pki/tls/certs/ServerCA.crt
 +SSLCertificateKeyFile /etc/pki/tls/certs/ServerCA.key
 +SSLCACertificateFile /etc/pki/tls/certs/RootCA.crt
 +:
 +SSLVerifyClient require
 +SSLVerifyDepth  1
 +:
 +</file>
  
 +==== - 如果要設定免輸入 Pin Code 啟動 Apache ====
 +<code>
 +openssl rsa -in /etc/pki/tls/certs/ServerCA.key -out /etc/pki/tls/certs/ServerCA.pem
 +Enter pass phrase for private/svncert.key:  <- 輸入 Pin Code
 +writing RSA key  <- 完成
 +</code>
 +
 +<code sh>
 +vi /etc/httpd/conf.d/ssl.conf
 +</code>
 +<file>
 +:
 +SSLCertificateKeyFile /etc/pki/tls/certs/ServerCA.pem
 +:
 +</file>
 +==== - 如果要設定廢止憑證 CRL 相關資訊 ====
 +  - 可以在 ssl.conf 內增加以下參數<file>
 +:
 +SSLCARevocationFile /etc/pki/tls/crl/ca-bundle-client.crl
 +:
 +</file>
 +  - 下載 crl 檔加入 /etc/pki/tls/crl/ca-bundle-client.crl, 以下以 **[[tech:openssl_cacrl]]** 內的 trysoft.crl 當範例<code sh>
 +openssl crl -inform PEM -in trysoft.crl -text -CAfile /etc/pki/tls/certs/RootCA.crt > CRL.pem
 +cat CRL.pem >> /etc/pki/tls/crl/ca-bundle-client.crl
 +</code>
 +  - 更改 ssl.conf 要重新啟動 Apache 才會生效, 以下是使用已經廢止的 ClientCA 憑證連線錯誤訊息<code>
 +[jonathan@pd920 certs]$ curl --cert ClientCA.pem https://mail.ichiayi.com/t.txt
 +Enter PEM pass phrase:
 +curl: (35) error:14094414:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate revoked
 +</code>
 +
 +===== - 重新啟動 Apache 就可完工 =====
 +<code sh>
 +service httpd restart
 +</code>
 +
 +===== 參考網址 =====
 +  * http://chinaunix.net/jh/13/523585.html
 +  * http://curl.haxx.se/docs/sslcerts.html
 +  * http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#ssloptions
 +  * http://polinwei.blogspot.com/2009/02/linux-centos-apache-server-with-ssl.html (啟動 httpd 不需輸入 server.key 密碼方式)
 +
 +{{tag>apache ssl openssl}}