目的: 讓apache中的網站可以用https(SSL)連線
環境: FreeBSD 6.1-R + Apache2.2
總共有以下步驟:
- 產生憑證
- 產生root CA
- 產生root private key
- 建立root require cert
- 利用root private key與root require建立public certification
- 產生server CA
- 產生server private key
- 建立server require cert
- 利用root public cert + server private key + server require cert來產生server public cert
- 產生root CA
- 設定Apache
- 設定private key位置
- 設定public cert位置
- 設定載入mod_ssl模組
實作:
- openssl genrsa -des3 -out rootCA.key 4096 (建立root private key)
- openssl req -new -key rootCA.key -out rootCA.req (建立root require cert)
- openssl x509 -days 3650 -req -sha1 -extensions v3_ca -signkey rootCA.key -in rootCA.req -out rootCA.crt (建立root public cert)
- 刪除rootCA.req, chmod 600 rootCA.key,以上完成root CA
- openssl genrsa -out server.key 4096 (建立server private key)
- openssl req -new -key server.key -out server.req (建立public cert request)
- openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA rootCA.crt -CAkey rootCA.key -CAserial rootCA.srl -CAcreateserial -in server.req -out server.crt (建立server public cert)
以上就這樣完成CA憑證的建立,接下來設定Apache
- 設定httpd.conf
- 將Loadmodule mod_ssl該行的註解移除
- 把"Include ~/apache22/extra/httpd-ssl.conf"前的註解拿掉
- 修改~/apache22/extra/httpd-ssl.conf
- 修改default virtual server中key檔與crt檔的位置
- 修改default virtual server加入ScriptAlias /cgi-bin/ "/path/to/cgi-bin/"
- apachectl -t
- apachectl -k restart
這樣就完成了https的設定
文章標籤
全站熱搜
