git clone https://github.com/diafygi/acme-tiny.git cd acme-tiny
创建账户私钥
创建一个 Let's Encrypt 账户私钥,以便让其识别你的身份
1
openssl genrsa 4096 > account.key
创建证书签名请求 (CSR) 的域名
1
openssl genrsa 4096 > domain.key
1 2 3 4 5 6 7 8
# For a single domain openssl req -new -sha256 -key domain.key -subj "/CN=yoursite.com" > domain.csr # For multiple domains (use this one if you want both www.yoursite.com and yoursite.com) openssl req -new -sha256 -key domain.key -subj "/" -addext "subjectAltName = DNS:yoursite.com, DNS:www.yoursite.com" > domain.csr # For multiple domains (same as above but works with openssl < 1.1.1) openssl req -new -sha256 -key domain.key -subj "/" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:yoursite.com,DNS:www.yoursite.com")) > domain.csr
配置验证域名所有权的服务
创建验证目录
1 2
# Make some challenge folder (modify to suit your needs) mkdir -p /var/www/challenges/
配置一个 HTTP 服务让 LETSENCRYPT 能下载验证文件
1 2 3 4 5 6 7 8 9 10 11 12
# Example for nginx server { listen80; server_name yoursite.com www.yoursite.com;
location /.well-known/acme-challenge/ { alias /var/www/challenges/; try_files$uri =404; }
...the rest of your config }
获取签名证书
1 2
# Run the script on your server python acme_tiny.py --account-key ./account.key --csr ./domain.csr --acme-dir /var/www/challenges/ > ./signed_chain.crt
# Example line in your crontab (runs once per month) 0 0 1 * * /path/to/renew_cert.sh 2>> /var/log/acme_tiny.log
重启nginx
问题
在安装 openssl 证书时提示如下报错:
Can't load /root/.rnd into RNG 140496635077056:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/root/.rnd