申請免費的HTTPS證書相關資料
參考資料:
-
一、Let’s Encrypt
二、TrustAsia
三、AlwaysOnSSL
四、Comodo
五、Cloudflare
六、AlphaSSL
HTTPS 檢測
蘋果ATS檢測
2017年1月1日起,蘋果強制所有 app 滿足 HTTPS,即 iOS9 推出的 App Transport Security (ATS) 特性。
輸入域名,檢查您的 iOS app 是否滿足 ATS 特性。
什么是ECC證書?
- 生成、簽署 ECC 證書,Nginx 部署雙證書教程 – 米飯粑
橢圓曲線密碼學(Elliptic curve cryptography,縮寫為ECC),一種建立公開密鑰加密的算法,基於橢圓曲線數學,其更適合於移動互聯網,有更好的安全性和更好的性能。ECC加密算法 1985年 提出,到 2005 年才在各種操作系統中獲得廣泛支持,2015 年開始被普遍性的部署。
可用於 ECDHE 數字簽名的算法主要有 RSA 和 ECDSA 內置 ECDSA 公鑰的證書一般被稱之為 ECC 證書,內置 RSA 公鑰的證書就是 RSA 證書。
渠道2: Let's Encrypt
- Let's Encrypt - Free SSL/TLS Certificates 官網
- 官方申請工具客戶端列表 ACME Client Implementations - Let's Encrypt - Free SSL/TLS Certificates
- 服務狀態檢測 Let's Encrypt Status
優點
- 開源免費
- 支持通配符域名證書
- HTTPS證書支持iOS企業版下載
缺點
- 證書有效期3個月
Let's Encrypt 的是否支持非80,443的其它端口來驗證?
答案是: NO,不支持! 因為安全問題!
此類問題解決方案就是使用DNS驗證.
參考資料:
-
I’ve been working on this project since 2012 and I can assure you that it was never possible to get a certificate via validation to port 8080! The HTTP-01 challenge has always required the use of port 80.
Port 80 and 443 Blocked By ISP - How to authenticate domain? - Let's Encrypt Community Support
Delegate the applications subdomain’s DNS and use LetsEncrypts domain validation option.
Support for ports other than 80 and 443 - Feature Requests - Let's Encrypt Community Support
If someone starts the software on port 81 or 8080 (non-root port, any user can use the port) on a shared server. He/she can validate all domains point to that server since the A records points to IP address, and get certificate to do MITM attack.
Letsencrypt doesnt work for different ports - Server - Let's Encrypt Community Support
Using the DNS-01 challenge type does not require any open ports and is currently your only option if you’re unable to use port 80 (with HTTP-01) and 443 (with TLS-SNI-01). The validation is performed through a TXT record you need to add to your DNS.
申請工具4: acme.sh
- 官方地址:Neilpang/acme.sh: A pure Unix shell script implementing ACME client protocol
- 官方文檔:How to use DNS API · Neilpang/acme.sh
優點
- 支持功能全
- 日志信息足夠詳細
缺點
- 安裝很麻煩
常用命令
# 使用測試服務器簽發證書(防止正式服務器簽發錯誤次數太多被封鎖)
# --staging
# export ACME_VERSION=2
# 通過 WebRoot 方式
acme.sh --issue -d bh.baixiangfood.com -w wwwroot --debug
# 第一次
export DP_Id="123456"
export DP_Key="asfadsfsdfasdfasdfasdfsdfasdfasdfasdf"
acme.sh --issue -d azyk.net -d '*.azyk.net' --dns dns_dp --debug
acme.sh --issue -d baixiangfood.azyk.net -d '*.baixiangfood.azyk.net' --dns dns_dp --debug
# 第一次之后
acme.sh --renew -d azyk.net --force --debug
# 導出相關證書到指定地方
acme.sh --install-cert -d azyk.net --key-file my.key --fullchain-file myfullchain.cer --debug
# 生成 .pfx 格式供 IIS 導入使用
# 因為 `fullchain.cer` = `ca.cer` + `*.azyk.net.cer`所以導入 IIS 里的時候選擇 `fullchain.cer` 才能一步到位,
# 否則會提示,證書不受信任,因為可能缺少 `ca.cer` 的原因.
#openssl pkcs12 -export -out azyk.net.pfx -inkey '*.azyk.net.key' -in '*.azyk.net.cer'
openssl pkcs12 -export -out my.pfx -inkey my.key -in myfullchain.cer
如何申請證書?
參考資料:
獲取免費的 Let’s Encrypt 泛域名 SSL 證書 - VirCloud's Blog - Learning&Sharing
#教程# 獲取免費的Let’s Encrypt泛域名野卡證書
注意事項:第一個 -d 后面不可以直接寫 *.xx.com ,一定要寫個普通單域名,第二個 -d 后面可以寫泛域名。建議使用3個 -d,即 @,www,和*.
將子域名的驗證權限用別的DNS服務商處理?
參考資料:
Linux 下使用 acme.sh 和 NS 代管申請 Let's Encrypt 免費通配符證書 - 燒餅博客
一種折衷的方法,將 ACME 認證域名單獨托管至支持 API 的 DNS 服務商。即使 API Key 泄露,攻擊者也無法篡改網站的其它 DNS 記錄。
本例采用的方法是 NS 代管一個任意子域名,然后利用 CNAME 轉發 ACME 挑戰子域名。
本例假設你擁有兩個域名 example.com 和 example.org,現在希望將 acme.example.com 轉交由 DigitalOcean 域名托管服務代管,並將兩個域名的 ACME 挑戰子域名轉發至這個子域名。DNS alias mode · Neilpang/acme.sh Wiki · GitHub
Do not remove the CNAME like : _acme-challenge.importantDomain.com after you issue the cert. It will be reused when acme.sh tries o renew the cert. The left cname record _acme-challenge.importantDomain.com doesn't harm to your domain at all. Just keep it there.
We have another parameter: --domain-alias, it has the same meaning with --challenge-alias.
But with --domain-alias you don't need to add _acme-challenge. prefix.
如何通過 443 端口申請證書?
acme.sh 支持 "tls-sni-01" 認證方式啦, let's encrypt - V2EX
使用 tls 方式驗證, 我們使用內置的 openssl server 完成驗證, 沒有增加新的依賴. 同時需要臨時占用本地的 443 端口, 所以請確保443 端口空閑.
Options and Params · Neilpang/acme.sh Wiki · GitHub
--tls Use standalone tls mode.
如何與IIS配合以便能正確簽發證書?
方法2:
- 打開 IIS 的對應 80 端口的網站
- 右鍵
添加虛擬目錄
- 別名設置為
.well-known
- 物理路徑設置為 Cygwin 的
/home/YOUR_USER_NAME/wwwroot/.well-known
路徑對應的 Windows下的路徑如:
C:\Cygwin\home\YOUR_USER_NAME\wwwroot\.wel-known
- 然后通過命令
acme.sh --issue -d x.com -w wwwroot
申請證書即可
方法1:
- 通過
mklink /d
將 物理路徑設置為 Cygwin 的/home/YOUR_USER_NAME/wwwroot/.well-known
路徑對應的 Windows下的路徑鏈接
到 IIS 網站目錄下.
DNSPod 服務提供商 泛域名 [野卡] 申請記錄:
√申請成功:
*.azyk.net
acme.sh --issue -d '*.azyk.net' --dns dns_dp --debug --staging
√申請成功:
*.sub1.azyk.net
acme.sh --issue -d '*.sub1.azyk.net' --dns dns_dp --debug --staging
√申請成功:
*.sub2.sub1.azyk.net
acme.sh --issue -d '*.sub2.sub1.azyk.net' --dns dns_dp --debug --staging
雖然證書能申請成功,但是在 域名解析控制台 卻無法正常添加解析記錄,提示:
泛解析級數超出限制
×申請失敗:
*.sub3.sub2.sub1.azyk.net
acme.sh --issue -d '*.sub3.sub2.sub1.azyk.net' --dns dns_dp --debug --staging
提示錯誤信息:
Error add txt for domain:_acme-challenge.sub3.sub2.sub1.azyk.net測試:1. 設置CNAME:_acme-challenge.sub2.sub1
=>_acme-challenge.azyk.net
2. 執行命令:acme.sh --issue -d '*.sub3.sub2.sub1.azyk.net' --challenge-alias azyk.net --dns dns_dp --debug --staging
3. 返回錯誤: *.sub3.sub2.sub1.azyk.net:Verify error:No TXT record found at _acme-challenge.sub3.sub2.sub1.azyk.net解決方案: 更換DNS服務商
理由: DNSPod 免費版本只支持2級通配符.
參考資料:
DNS alias mode · Neilpang/acme.sh Wiki · GitHub
Even with ACME v2 wildcard cert:
- First set domain CNAME:
_acme-challenge.importantDomain.com => _acme-challenge.aliasDomainForValidationOnly.com - Issue a cert:
acme.sh --issue -d importantDomain.com --challenge-alias aliasDomainForValidationOnly.com --dns dns_cf
- First set domain CNAME:
DNSPod 域名解析 - 全部域名 上方 - 切換到騰訊雲控制台 - 域名 - 域名設置 - 解析參數
解析參數:
子域名級別 3級
泛解析級別 2
注意: 以上的解析只是針對二級域名,通配符只能匹配一個級別的子域名,如果是三級域名需要用 *.example來匹配。使用不同套餐版本的解析能設定的泛解析級別數不同。解析套餐版本 泛解析級別 免費套餐 2 個人專業版套餐 4
Linux 下使用 acme.sh 和 NS 代管申請 Let's Encrypt 免費通配符證書 - 燒餅博客
一種折衷的方法,將 ACME 認證域名單獨托管至支持 API 的 DNS 服務商。即使 API Key 泄露,攻擊者也無法篡改網站的其它 DNS 記錄。
本例采用的方法是 NS 代管一個任意子域名,然后利用 CNAME 轉發 ACME 挑戰子域名。
本例假設你擁有兩個域名 example.com 和 example.org,現在希望將 acme.example.com 轉交由 DigitalOcean 域名托管服務代管,並將兩個域名的 ACME 挑戰子域名轉發至這個子域名。Let's encrypt 通配域名(二級, 三級) - 個人文章 - SegmentFault 思否
需要在DNS中添加 b.example.com 的A記錄, 這樣在 Let's encrypt 發起挑戰的時候才能解析到這個域名.
1.創建 b.example.com 的A記錄
2.執行命令申請通配域名(三級域名)
certbot certonly --manual \ -d '*.b.exampple.com'Acme.sh supports ACME v2 wildcard now - Client dev - Let's Encrypt Community Support
從文中舉例來看是支持的-d *.sub.acme.sh
申請證書時出現SERVFAIL looking up CAA for Secondlevel.azyk.net
錯誤
x.azyk.net
:Verify error:DNS problem: SERVFAIL looking up CAA for Secondlevel.azyk.net
參考資料:
What is a CAA record? - DNSimple Help
Querying CAA records
dig google.com type257Global DNS Propagation Checker - What's My DNS?
支持檢測多個國家的DNS解析信息,包括CAA信息.
dig dns lookup and traceroute tools | traceroute-online.com
支持在線查詢指定域名的 CAA 記錄
Run DIG from our server
using the type ANY flag (-t any)測試
google.com
時返回的結果;; ANSWER SECTION:
……
google.com. 21599 IN CAA 0 issue "pki.goog"支持在線查詢指定域名的 CAA 記錄
-
添加CAA記錄
您想要只允許由 symantec.com 來頒發域名 midengd.xyz 的證書,並且發送違規通知到郵箱 admin@midengd.xyz。您可以按照以下方式來配置CAA記錄。
主機記錄 記錄值
@ 0 issue “symantec.com”
@ 0 iodef “mailto:admin@midengd.xyz” Linux 下使用 acme.sh 配置 Let's Encrypt 免費 SSL 證書 + 通配符證書 - 燒餅博客
給 example.com 增加一個 CAA 記錄為 0 issue "letsencrypt.org" 這樣可以告訴 Let’s Encrypt 的 CA ,你授權給他們簽發 SSL 證書
dig TXT _acme-challenge.example.com @9.9.9.9 +short申請ssl證書報提示caa提示 - weizy81 - 博客園
dig -t TYPE257 example.com
發現我的 PowerDNS 確實是返回了一個 SERVFAIL
CAA 記錄由兩部分組成:一個 flags 和 一個 tag 對。flags 是一個字節,當前只有最高位被用於 Issuer Critical,代表這個 tag 對的重要性
當前支持的 tag 包括:issue issuewild iodef。
issue 表示允許 CA 機構簽署證書,issuewild 表示允許 CA 機構簽署 wildcard 證書,iodef 表示簽署證書時通過指定的方式通知域名持有者。
在Cygwin里安裝 acme.sh 步驟
- 准備好 Cygwin 環境
- 安裝好 curl, openssl and crontab
在Windows環境安裝Cygwin工具包的步驟
已有.cer和.key文件如何供IIS導入證書?
#openssl pkcs12 -export -out azyk.net.pfx -inkey '*.azyk.net.key' -in '*.azyk.net.cer'
#因為 `fullchain.cer` = `ca.cer` + `*.azyk.net.cer`所以導入 IIS 里的時候選擇 `fullchain.cer` 才能一步到位,
#否則會提示,證書不受信任,因為可能缺少 `ca.cer` 的原因.
openssl pkcs12 -export -out azyk.net.pfx -inkey '*.azyk.net.key' -in 'fullchain.cer'
參考資料:
-
1、在你的服務器上,解壓下載的證書 zip 文件,並重命名保存為 your_domain_name.cer。
2、 打開 IIS 管理器,開始菜單(Start)-> 管理工具(Administrative Tools)-> IIS 管理器(Internet Information Services (IIS) Manager)
3、你可以看到連接(Connections)下的主機,點擊你服務器的主機名。
4、在中間菜單中,IIS 部分,雙擊 服務器證書(Server Certificates)。
5、在操作菜單,點擊 完成證書請求(Complete Request Certificate) 向導。
6、在完成證書請求向導,指定證書認證響應(Specify Certificate Authority Response)頁,選擇剛剛解壓的文件。
7、填寫一個名稱,用於辨別該證書是哪張證書。
8、證書安裝到這里就完成了。 How to Make a .pfx File When Given .crt and .key Files | SherWeb
openssl pkcs12 -export -out domain.name.pfx -inkey domain.name.key -in domain.name.crt
Using Let's Encrypt with IIS on Windows - Rick Strahl's Web Log
This script produces a PFX file which can then be imported into IIS.
There are also tools to install and update existing certificates into IIS but it looks there are currently some changes in the API that made this not work for me. I wasn't able to even get the tools to load.
You can manually install the certificate with:
certutil -importPFX "c:\admin\certs\codepaste2016-02-28--20:22" –p passwordiis - IIS7: How to import public key and private key as two seperate files? - Server Fault
簽發證書成功后產生的文件及其各自用途
例子:通配符域名生成成功后產生了以下文件:
'./.acme.sh/*.azyk.net':
'*.azyk.net.cer'
'*.azyk.net.conf'
'*.azyk.net.csr'
'*.azyk.net.csr.conf'
'*.azyk.net.key'
ca.cer
fullchain.cer
各種后綴的文件意義和用途相關參考資料:
letsencrypt fullchain.pem is cert.pem + chain.pem | Awhan Patnaik
here is how you verify that fullchain.pem is just a concatenation of cert.pem and chain.pem.
Please note that the order of those two files is important
diff fullchain.pem <(cat cert.pem chain.pem)
得此靈感通過Beyond Compare工具對比 之后發現的確是 fullchain.cer
= ca.cer
+ *.azyk.net.cer
所以導入 IIS 里的時候選擇 fullchain.cer
才能一步到位,否則會提示,證書不受信任,因為可能缺少 ca.cer
的原因.
how to update acme.sh · Issue #187 · Neilpang/acme.sh
我放在nginx配置文件里面的只有fullchain.cer和domain.com.key
那么其他文件是什么作用?
其他的文件沒有作用, 為的是別的服務器,不光是nginx。 你需要什么就指定什么,別的不管。獲取免費的 Let’s Encrypt 泛域名 SSL 證書 - VirCloud's Blog - Learning&Sharing
[Sat Mar 17 16:10:54 CST 2018] The intermediate CA cert is in /root/.acme.sh/owen.ml/ca.cer
[Sat Mar 17 16:10:54 CST 2018] And the full chain certs is there: /root/.acme.sh/owen.ml/fullchain.cer-
cert.pem #server cert only
privkey.pem #private key
chain.pem #intermediates
fullchain.pem #server cert + intermediates [Solved] Why isn't my certificate trusted? - Server - Let's Encrypt Community Support
The difference is, the ‘chain.pem’ file contains a cross signature from an IdenTrust root which is present in most browsers today.
The ‘fullchain.pem’ references the ISRG root certificate, which is not yet present in most browsers as Let’s Encrypt are still in the process of applying to have it included.Currently both files should be based on the same chain provided by the Let’s Encrypt CA,
So when I downloaded ‘fullchain.pem’ via FTP and renamed it to ‘fullchain.crt’ to check it, I ended up with an error “this certificate cannot be verified up to a trusted certification authority”. But downloading ‘chain.pem’ and renaming it ‘chain.crt’ showed me the cross signed intermediate.
-
注意, 默認生成的證書都放在安裝目錄下: ~/.acme.sh/, 請不要直接使用此目錄下的文件
正確的使用方法是使用 --installcert 命令,並指定目標位置, 然后證書文件會被copy到相應的位置, Nginx 的配置 ssl_certificate 使用 /etc/nginx/ssl/fullchain.cer ,而非 /etc/nginx/ssl/.cer ,否則 SSL Labs 的測試會報 Chain issues Incomplete 錯誤 SSL中,公鑰、私鑰、證書的后綴名都是些啥? - 劉長元的回答 - 知乎
CA,certificate authority。證書局,用於制作、認證證書的第三方機構,我們假設營業執照非常難制作,就像身份證一樣,需要有制證公司來提供,並且提供技術幫助工商局驗證執照的真偽。
那些證書相關的玩意兒(SSL,X.509,PEM,DER,CRT,CER,KEY,CSR,P12等) - guogangj - 博客園
CRT - CRT應該是certificate的三個字母,其實還是證書的意思,常見於NIX系統,
CER - 還是certificate,還是證書,常見於Windows系統,
KEY - 通常用來存放一個公鑰或者私鑰,
CSR - Certificate Signing Request,即證書簽名請求,這個並不是證書,而是向權威證書頒發機構獲得簽名證書的申請,其核心內容是一個公鑰
PFX/P12 - predecessor of PKCS#12,對nix服務器來說,一般CRT和KEY是分開存放在不同文件中的,但Windows的IIS則將它們存在一個PFX文件中,(因此這個文件包含了證書及私鑰)這樣會不會不安全?應該不會,PFX通常會有一個"提取密碼",你想把里面的東西讀取出來的話,它就要求你提供提取密碼What is the difference between a .CRT and a .CER file?
The file extensions .CRT and .CER are interchangeable.
申請工具3: 瀏覽器在線申請 SSL For Free Online
- Get HTTPS for free!
- SSL For Free - Free SSL Certificates in Minutes
- FreeSSL.org - 一個申請免費HTTPS證書的網站
- 域名型(DV)免費SSL證書 - SSL 證書 - 文檔首頁 - 騰訊雲文檔平台 - 騰訊雲
優點
- 在線即可用,不需要安裝任何軟件
缺點
- 國內某些域名無法正常訪問導致無法簽發證書
- 需要全手動配置
- 無法自動續簽
申請工具2: Certify SSL Manager
manage free https certificates for IIS
The app is free for up to 5 managed sites per server
官方地址:Certify Your Windows IIS Website - simple free certificates powered by Let's Encrypt
下載地址:Certify Your Windows IIS Website - simple free certificates powered by Let's Encrypt
優點
- 有UI運行界面
- 大部分情況一路點擊即可完成,需要手動設置的很少
- 支持自動配置 IIS 的 MIME 類型
- 支持在請求證書前自我檢查配置是否正常
- 自動續簽證書實踐時有效.
缺點
- 許多選項不太明白啥功能
- 證書申請失敗時錯誤信息不夠詳細(無法輔助排查某些特殊情況下無法正常簽發證書的問題原因)
使用步驟簡述
- 下載最新版本
- 安裝並運行
- TODO
如何自動續簽證書?
程序本身有這個功能。 原理是:通過安裝成系統服務的形式. 但是實際操作過程中,能夠成功生效並續簽.
申請工具1: Windows ACME Simple (WACS)
A simple ACME client for Windows - for use with Let's Encrypt. (Formerly known as letsencrypt-win-simple (LEWS))
官方地址:PKISharp/win-acme: win-acme - A Simple ACME Client for Windows (for use with Let's Encrypt)
下載地址:Releases · PKISharp/win-acme
優點
- 手動操作比較多,相對比較靈活?
缺點
- 命令行運行界面
- 需要手動輸入域名,網站地址
- 需要手動配置 IIS 的 MIME 類型
- 自動續簽證書實踐不成功.
- 證書申請失敗時錯誤信息不夠詳細(無法輔助排查某些特殊情況下無法正常簽發證書的問題原因)
使用步驟簡述
- 下載最新版本
- 解壓后運行
letsencrypt.exe
- 輸入
M
開始手動申請 - TODO
如何自動續簽證書?
程序本身有這個功能。 原理是:通過創建一個系統任務計划任務來運行. 但是實際操作過程中,一直未成功生效過.囧
渠道1: StartSSL
優點
- 證書有效期1年
- 老牌子
缺點
- HTTPS證書不支持iOS企業版下載
- 被國內公司玩壞了?
申請新域名證書的步驟
參考資料:
二次登錄網站的步驟
- 雙擊"StartSSL登錄證書.pfx" 導入 密碼:xxx
- 登錄網站:https://www.startssl.com/ - 點擊“Authenticate”
如何續簽登錄證書?
續簽時,使用原來的帳號重新注冊,即可。
附件列表