Lets Encrypt 免費的 SSL 憑證,現在終於看到有可以讓我順利安裝的 script 了,如下

環境
Python 2.6.x
Apache 2.2.31

python 需要安裝 argparse

easy_install argparse

# 建立目錄

mkdir /etc/letsencrypt
cd /etc/letsencrypt

# 下載 script

git clone https://github.com/diafygi/acme-tiny.git

# 產生私鑰

openssl genrsa 4096 > account.key
openssl genrsa 4096 > domain.key

# 憑證請求

openssl req -new -sha256 -key domain.key -subj "/CN=ssorc.tw" > domain.csr

# 要一個路徑證明網站是你自已的,script 會在這路徑產生字串檔,然後驗證網站連結連得到

mkdir -p /var/www/vhosts/ssorc.tw/httpdocs/.well-known/acme-challenge

# 產生憑證

/usr/local/python/bin/python acme-tiny/acme_tiny.py --account-key account.key --csr domain.csr --acme-dir /var/www/vhosts/ssorc.tw/httpdocs/.well-known/acme-challenge > domain.crt

# 中繼憑證,從 lets encrypt 官網抓的

wget -O - https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > intermediate.pem

# 合併網站憑證與中繼憑證

cat domain.crt intermediate.pem > chained.pem

# 產生 DH

openssl dhparam -out dhparam.pem 2048

# nginx 設定

ssl on;
ssl_certificate /etc/letsencrypt/chained.pem;
ssl_certificate_key /etc/letsencrypt/domain.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DH$
ssl_session_cache shared:SSL:50m;
ssl_dhparam /etc/letsencrypt/dhparam.pem;
ssl_prefer_server_ciphers on;

# apache 設定

SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
SSLHonorCipherOrder on
SSLCertificateFile /etc/letsencrypt/chained.pem
SSLCertificateKeyFile /etc/letsencrypt/domain.key
SSLOpenSSLConfCmd DHParameters /etc/letsencrypt/dhparam.pem

# lets encrypt 有效期只有三個月,所以要固定時間 update

#!/bin/sh
cd /etc/letsencrypt
/usr/local/bin/python acme-tiny/acme_tiny.py --account-key account.key --csr domain.csr --acme-dir /var/www/vhosts/ssorc.tw/httpdocs/.well-known/acme-challenge > domain.crt || exit
wget -O - https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > intermediate.pem
cat domain.crt intermediate.pem > chained.pem
service nginx reload
# or
# service httpd graceful

參考 http://www.leavesongs.com/SHARE/lets-encrypt-guide.html

最後修改日期: 2016 年 09 月 10 日

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。