Posts

Showing posts with the label cloudflare

使用 acme.sh 搭配 Let's encrypt 申請 wildcard ssl 憑證

Image
之前一直都是使用 certbot 套件 不過換到 CentOS 8 後 這個套件到今天(2020.05.28)為止還沒支援就是 由於 certbot 是用 pythlon 開發的 所以安裝時會安裝一堆相依的套件 這也是我一直不喜歡用 certbot 的原因 會間接搞亂我的環境 後來找到 acme.sh 是使用 shell script 撰寫的 相對來說單純很多 安裝也很簡單 這個範例是搭配 Cloudflare DNS 做設定 安裝 acme.sh 我是使用 root 執行安裝的 curl  https://get.acme.sh | sh 所以安裝完會出現 /root/.acme.sh 這個資料夾 取得 Cloudflare 的 key 登入你的 cloudflare 帳號後 到這個頁面  https://dash.cloudflare.com/profile/api-tokens 點選下方「Global API Key」右邊的 View 認證完後會取得一組 Key 申請 SSL 憑證 在 /root/ 下新增一個 ssl_cert.sh 檔案 其中 yourdomain.tld 為你自己的網域名稱,如 google.com 因為有指定目錄於 /etc/letsencrypt 中 所以憑證應該會出現在 /etc/letsencrypt/yourdomain.tld 下 由於是 wildcard 的關係,所以會指定兩個 domain 分別為 yourdomian.tld 及 *.yourdomain.tld 請注意,務必讓 yourdomain.tld 在第一個,如果讓 *.yourdomain.tld 在前面的話,你的資料夾就會是 *.yourdomain.tld export CF_Key="your global api key" export CF_Email="你的 cloudflare 登入的帳號(信箱)" /root/.acme.sh/acme.sh --issue -d yourdomain.tld -d *.yourdomain.tld --cert-home /etc/letsencrypt --keylength 2048 --dns dns_cf \ --reloadcmd "system...