Trustix Linux 建立及發行 CA 憑證(Copy from home)
8 月 24
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
製作亂數檔
/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 root.key 2048
openssl req -new -key root.key -out root.csr
(這步可以不用做, 因為我們要先消除 使用 root.key 時會問密碼的限制)
移除CA製作時的密碼問答
(使用不需密碼問答的 ca.key 用在 apache 時, 才比較方便, 不然啟動 apache 時會卡住)
openssl rsa -in root.key -out root-nopasswd.key
openssl req -new -key root-nopasswd.key -out root-nopasswd.csr
(建出來的 csr 與先前有密碼的 csr 是一樣的)
自簽憑證
openssl x509 -days 3650 -signkey root.key -in root.csr -req -out root.crt (這個可以不採用, 我們採用下面這行)
openssl x509 -days 3650 -signkey root-nopasswd.key -in root-nopasswd.csr -req -out root-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/root.crt -CAkey ../rootca/root.key -CAcreateserial -in server.csr -out server.crt (這組可以不要)
openssl x509 -req -days 3650 -CA ../rootca/root-nopasswd.crt -CAkey ../rootca/root-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/