3月 15, 2012

Lighttpd SSL 加密連線設定

使用 OpenSSL 製作憑證


1. 產生 Private Key
# openssl genrsa -out private.key 1024

2. 使用私鑰產出 Certificate Signing Request(CSR)
# openssl req -new -key private.key -out server.csr

3. 產生 SSL Certificate(CRT)
# openssl x509 -req -days 365 -in server.csr -signkey private.key -out server.crt

4. 把 Private Key 與 CRT 倒在一起,成為 PEM 檔案
# cat private.key server.crt > server.pem

修改 Lighttpd 連線設定


1. 把檔案都丟到 /etc/lighttpd/ssl/ 下面
# cp * /etc/lighttpd/ssl/

2. 更改檔案擁有者
# chown -R www-data:www-data /etc/lighttpd/ssl/*

3. 設定 lighttpd 的 SSL 模組
# vim /etc/lighttpd/conf-enabled10-ssl.conf
$SERVER["socket"] == "0.0.0.0:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/ssl/server.pem"
}
4. 重新啟動 lighttpd
憑證只有在 lighttpd 啟動時會載入一次,所以當有新憑證產生,記得重新啟動。
# /etc/init.d/lighttpd restart

沒有留言:

張貼留言