Let's Encrypt,免費好用的 HTTPS 認證

來源:互聯網
上載者:User

標籤:span   oss   rsa   引導   --   驗證   指令碼   strong   div   

https://imququ.com/post/letsencrypt-certificate.html

1、

openssl genrsa 4096 > account.key

2、私密金鑰

openssl genrsa 4096 > domain.key

3、csr檔案產生

openssl.cnf檔案位置,可以用

find / -name ‘openssl.cnf‘

尋找

DNS網域名稱,可以多個,都要可以訪問

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

 

4.1、驗證準備

目錄

mkdir ~/www/challenges/

訪問引導,注意目錄

server {
listen 80; server_name www.yoursite.com yoursite.com;   #驗證訪問 location ^~ /.well-known/acme-challenge/ { alias /home/xxx/www/challenges/; try_files $uri =404; } location / {
     #其他訪問轉向https rewrite ^/(.*)$ https://yoursite.com/$1 permanent; }}

4.2 指令檔

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

5 驗證

注意用到了1、2的兩個檔案,並提供驗證目錄

python acme_tiny.py --account-key ./account.key --csr ./domain.csr --acme-dir ~/www/challenges/ > ./signed.crt

通過驗證後,目前的目錄下就會產生一個 signed.crt 認證檔案。

6 合并認證

wget -O - https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem > intermediate.pemcat signed.crt intermediate.pem > chained.pem

7開啟(nginx配置,其他和http配置一樣)

server {    server_name YOUR_DOMAINNAME_HERE;    listen 443;    ssl on;    ssl_certificate     ~/www/ssl/chained.pem;    ssl_certificate_key ~/www/ssl/domain.key;}

 

6自動更新指令碼

Let‘s Encrypt 簽發的認證只有 90 天有效期間,用指令碼定期更新。

指令碼內容和上面步驟一樣,驗證並獲得認證,合并認證,最後重載nginx,注意目錄

#!/bin/bashcd /home/xxx/www/ssl/python acme_tiny.py --account-key account.key --csr domain.csr --acme-dir /home/xxx/www/challenges/ > signed.crt || exitwget -O - https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem > intermediate.pemcat signed.crt intermediate.pem > chained.pemservice nginx reload

7定期執行指令碼

可執行許可權

chmod a+x renew_cert.sh

定期執行(每月一次)

0 0 1 * * /home/xxx/shell/renew_cert.sh >/dev/null 2>&1

 

Let's Encrypt,免費好用的 HTTPS 認證

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.