如何使用Mkchain構(gòu)建一個(gè)有效的SSL證書鏈
關(guān)于Mkchain
Mkchain是一款功能強(qiáng)大的開源安全工具,在該工具的幫助下,廣大研究人員可以輕松構(gòu)建一個(gè)有效的SSL證書鏈。除此之外,該工具還可以幫助我們修復(fù)不完整的SSL證書鏈或下載所有缺失的CA證書。我們甚至還可以利用該工具從遠(yuǎn)程服務(wù)器下載所有的證書,以修復(fù)你自己的證書鏈。
工具要求
當(dāng)前版本的Mkchain需要使用到下列外部實(shí)用工具:
OpenSSL(v1.10g/h)
GNU/Linux(Debian或CentOS)
Bash(v4.4.19)
工具下載
首先,廣大研究人員可以使用下列命令將該項(xiàng)目源碼克隆至本地:
git clone https://github.com/trimstray/mkchain
然后切換到項(xiàng)目目錄中,執(zhí)行工具安裝腳本:
./setup.sh install
將指向bin/mkchain的符號(hào)連接移動(dòng)到/usr/local/bin。
工具使用手冊(cè)可以在/usr/local/man/man8中找到。
最后,使用下列命令即可開始使用Mkchain:
mkchain -i /data/certs -o /data/chain.crt
工具參數(shù)
該工具提供了下列運(yùn)行參數(shù)選項(xiàng):
Usage:
mkchain <option|long-option>
Options:
--help 顯示工具幫助信息和退出
--debug 在屏幕上顯示調(diào)試信息(調(diào)試模式)
-i, --in 添加要整合的證書(單/多文件、包含SSL證書的目錄或遠(yuǎn)程域名)
-o, --out 將所有的結(jié)果(證書鏈)存儲(chǔ)到文件中
--with-root 將根證書添加到證書鏈
工具運(yùn)行機(jī)制
我們以ssllabs證書鏈為例,mkchain項(xiàng)目中提供了一個(gè)example/ssllabs.com目錄,其中有一個(gè)all目錄(該目錄中包含了構(gòu)建證書鏈所需要的全部證書)和server_certificate目錄(僅包含服務(wù)器證書)。
ssllabs.com域名的正確證書鏈(openssl命令結(jié)果):
Certificate chain
0 s:/C=US/ST=California/L=Redwood City/O=Qualys, Inc./CN=ssllabs.com
i:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2012 Entrust, Inc. - for authorized use only/CN=Entrust Certification Authority - L1K
1 s:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2012 Entrust, Inc. - for authorized use only/CN=Entrust Certification Authority - L1K
i:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2009 Entrust, Inc. - for authorized use only/CN=Entrust Root Certification Authority - G2
2 s:/C=US/O=Entrust, Inc./OU=See www.entrust.net/legal-terms/OU=(c) 2009 Entrust, Inc. - for authorized use only/CN=Entrust Root Certification Authority - G2
i:/C=US/O=Entrust, Inc./OU=www.entrust.net/CPS is incorporated by reference/OU=(c) 2006 Entrust, Inc./CN=Entrust Root Certification Authority
場景一
在這個(gè)場景中,我們將鏈接所有證書:
場景二
在這個(gè)場景中,我們只會(huì)使用服務(wù)器證書,并用它來獲取剩余所需的證書,然后將所有的證書鏈接:
證書路徑
Mkchain允許使用兩種證書路徑:
工具使用樣例
mkchain --in Root.crt --in Intermediate1.crt --in Server.crt --out bundle_chain_certs.crt
mkchain --in /tmp/certs --out bundle_chain_certs.crt --with-root
mkchain -i Server.crt -o bundle_chain_certs.crt
mkchain -i https://incomplete-chain.badssl.com/ --with-root
許可證協(xié)議
本項(xiàng)目的開發(fā)與發(fā)布遵循GPL-3.0開源許可證協(xié)議。
項(xiàng)目地址
Mkchain:【GitHub傳送門】
參考資料
https://medium.com/@superseb/get-your-certificate-chain-right-4b117a9c0fce
https://support.dnsimple.com/articles/what-is-ssl-certificate-chain/
本文作者:Alpha_h4ck, 轉(zhuǎn)載請(qǐng)注明來自FreeBuf.COM