Trustix 建立 CA 憑證
參考(待補充):
http://www.twbsd.org/chs/book/index.php?ch=14
root: LibIL-CA
server: libil.dyndns.org
建立自家主機根憑證
vi /etc/ssl/openssl.cnf
將 dir = ./demoCA
改成 dir = /etc/ssl
製作亂數檔
openssl rand -out /etc/ssl/private/.rand 2048
chmod og-rwx /etc/ssl/private/.rand
開始製作 Root CA
cd /etc/ssl/private
mkdir rootca
cd rootca
openssl genrsa -des3 -out rootca.key 2048
openssl req -new -key rootca.key -out rootca.csr
(這步可以不用做, 因為我們要先消除 使用 rootca.key 時會問密碼的限制)
移除CA製作時的密碼問答
(使用不需密碼問答的 ca.key 用在 apache 時, 才比較方便, 不然啟動 apache 時會卡住)
openssl rsa -in rootca.key -out rootca-nopasswd.key
openssl req -new -key rootca-nopasswd.key -out rootca-nopasswd.csr
(建出來的 csr 與先前有密碼的 csr 是一樣的)
自簽憑證
openssl x509 -days 3650 -signkey rootca.key -in rootca.csr -req -out rootca.crt (這個可以不採用, 我們採用下面這行)
openssl x509 -days 3650 -signkey rootca-nopasswd.key -in rootca-nopasswd.csr -req -out rootca-nopasswd.crt
(以上產出來的 crt 是不同的, 因為 root.key 與 root-nopasswd.key 兩個檔案是完全不同的)
-- 這段可以不用, 我們要另外建 server.crt --
cp /usr/share/doc/apache-2.0.59/conf/ssl.conf /etc/httpd/conf.d/ssl.conf
vi /etc/httpd/conf.d/ssl.conf
修改以下各行
DocumentRoot "/home/httpd/html"
#ServerName www.example.com:443
#ServerAdmin you@example.com
ErrorLog /var/log/httpd/ssl-error_log
TransferLog /var/log/httpd/ssl-access_log
SSLCertificateFile /etc/httpd/conf/certs/rootca/root-nopasswd.crt
SSLCertificateKeyFile /etc/httpd/conf/certs/rootca/root-nopasswd.key
service httpd restart
check https://your-website.where.is/
-- 這段可以不用, 我們要另外建 server.crt --
若想另外建一個屬於 web site 的 server 認證
cd /etc/ssl/private
mkdir server
cd server
openssl genrsa -out server.key 2048
(不同於根憑證的 -des3 )
建立申請檔
openssl req -new -key server.key -out server.csr
由 root 簽給 server 的 crt
openssl x509 -req -days 3650 -CA ../rootca/rootca.crt -CAkey ../rootca/rootca.key -CAcreateserial -in server.csr -out server.crt (這組可以不要)
openssl x509 -req -days 3650 -CA ../rootca/rootca-nopasswd.crt -CAkey ../rootca/rootca-nopasswd.key -CAcreateserial -in server.csr -out server-nopasswd.crt
正式將 sever 的 憑證安裝給 web server
cp /usr/share/doc/apache-2.0.59/conf/ssl.conf /etc/httpd/conf.d/ssl.conf
vi /etc/httpd/conf.d/ssl.conf
修改以下各行
DocumentRoot "/home/httpd/html"
#ServerName www.example.com:443
#ServerAdmin you@example.com
ErrorLog /var/log/httpd/ssl-error_log
TransferLog /var/log/httpd/ssl-access_log
SSLCertificateFile /etc/httpd/conf/certs/server.crt
SSLCertificateKeyFile /etc/httpd/conf/certs/server.key
SSLCACertificateFile /etc/httpd/conf/certs/root-nopasswd.crt
Trustix 啟用 httpd 的 ssl
vi /etc/sysconfig/httpd
加入 HTTPDARGS="-D SSL"
若沒加, 則會出現以下錯誤訊息
Starting httpd: Syntax error on line 28 of /etc/httpd/conf.d/ssl.conf:
Invalid command 'SSLRandomSeed', perhaps mis-spelled or defined by a module not included in the server configuration
service httpd restart
check https://your-website.where.is/
註: SSL 要使用的安全性設定 (請參考 http://forum.slime.com.tw/thread211482.html)
可在 SSLCipherSuite 這裡來設定支援的 SSL 版本, 建議 SSL v2 不用開啟了
例如: 以下這行來說, SSLv2 前有個 "+" 號, 表示會使用 SSLv2, 若不想用, 就把 "+" 號改成 "!" 號
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
並且另外加入 SSLProtocol all -SSLv2 , 以停止使用 SSLv2
|