====== Apache 設定雙向 SSL 認證方式 ======
* 需要自己產生免費 Server 憑證,請參考 **[[tech:openssl_caserver]]**。
* 將產生的 ServerCA.crt, ServerCA.key, RootCA.crt 放入 /etc/pki/tls/certs/ 內
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
===== - 設定 Apache 內的 ssl.conf =====
vi /etc/httpd/conf.d/ssl.conf
:
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
:
==== - 如果要設定免輸入 Pin Code 啟動 Apache ====
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 <- 完成
vi /etc/httpd/conf.d/ssl.conf
:
SSLCertificateKeyFile /etc/pki/tls/certs/ServerCA.pem
:
==== - 如果要設定廢止憑證 CRL 相關資訊 ====
- 可以在 ssl.conf 內增加以下參數
:
SSLCARevocationFile /etc/pki/tls/crl/ca-bundle-client.crl
:
- 下載 crl 檔加入 /etc/pki/tls/crl/ca-bundle-client.crl, 以下以 **[[tech:openssl_cacrl]]** 內的 trysoft.crl 當範例
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
- 更改 ssl.conf 要重新啟動 Apache 才會生效, 以下是使用已經廢止的 ClientCA 憑證連線錯誤訊息
[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
===== - 重新啟動 Apache 就可完工 =====
service httpd restart
===== 參考網址 =====
* 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}}