IOS mobileconfig簽名驗證

摘抄自:天狐博客

前言:非常感謝這位天狐博客的網(wǎng)友,其實他寫的方法已經(jīng)非常到位了,為了方便查找,我就寫這篇文章供參考學(xué)習(xí)。

獲取設(shè)備udid是實現(xiàn)超級簽名的首要任務(wù),也是其中重要的一環(huán),下面介紹幾種方法來對mobileconfig文件進行簽名。

Safari獲取設(shè)備udid需要安裝.mobileconfig文件,

但是通常直接安裝.mobileconfig文件后,會發(fā)現(xiàn)描述文件顯示"未簽名"或者“unsigned”等紅色字樣,所以接下來我們的主要工作就是讓描述文件變成綠色的"已驗證"字樣。

方法一:導(dǎo)出蘋果證書進行簽名

1、從鑰匙串(keychain)中導(dǎo)出證書

實用工具->鑰匙串訪問->選擇要導(dǎo)出的證書,導(dǎo)出生成p12文件 InnovCertificates.p12

然后轉(zhuǎn)換成 InnovCertificates.pem 文件

2、p12證書轉(zhuǎn)pem格式方法:

p12在線轉(zhuǎn)換pem?SSL Converter - Convert SSL Certificates to different formats

(證書)cer.p12文件 轉(zhuǎn)cer.pem文件

openssl pkcs12 -clcerts -nokeys -out cer.pem -in cer.p12

(私鑰)key.p12文件轉(zhuǎn)key.pem文件

openssl pkcs12 -nocerts -out key.pem -inkey.p12

3、下載 Apple Root Certificate ?和 Apple Intermediatediate Certificate:

(對于本篇文章 .mobileconfig文件的驗證我使用了蘋果的以下兩個證書.

Apple Root Certificate(蘋果根證書)

Apple Application Integration Certificate (蘋果應(yīng)用集成證書 )

你也可以使用這些證書或者蘋果提供的其他證書 地址: http://www.apple.com/certificateauthority/

下載的文件中包括證書(cer)和私鑰(key)

(在命令行中讀取證書,參考鏈接 info.ssl.com/article.aspx?id=12149)

4、簽名和驗證.mobileconfig文件

在Mac終端cd到該路徑下,執(zhí)行如下命令:

openssl smime -sign -in Example.mobileconfig -out SignedVerifyExample.mobileconfig -signer InnovCertificates.pem -certfile root.crt.pem -outform der -nodetach

結(jié)果就得到已經(jīng)簽名且驗證的.mobileconfig文件。

方法二:向服務(wù)端索要https服務(wù)器證書相關(guān)的兩個文件,后綴名為.crt和.key兩個文件

1、通過在線openssl工具把.crt和.key合成為.pem文件?pem格式轉(zhuǎn)化

2、將.crt ?.key ? .pem文件放在同一文件夾目錄下

3、在Mac終端cd到該路徑下,執(zhí)行如下命令:

openssl rsa -in ybs.key -out ybsnopass.key

此時文件夾下,會多出一個ybsnopass.key文件,然后終端再執(zhí)行命令:

openssl smime -sign -in unsigned.mobileconfig -out signed.mobileconfig -signer ybs.crt -inkey ybsnopass.key -certfile ybs_ssl.pem -outform der -nodetach

此時文件夾下會多出一個signed.mobileconfig,這便是我們簽名后的.mobileconfig,將簽名后的描述文件放到服務(wù)器,然后在safari中下載的描述文件的安裝界面就會顯示綠色的“已驗證”。

方法三:腳本簽名

借助于強大的github,找到了一個python腳本進行簽名:地址:

1、簽名.mobileconfig文件(AcrobatPro.mobileconfig為未簽名的.mobileconfig文件)

profile_signer.py與?mobileconfig?放在同一目錄,終端進入目錄執(zhí)行

./profile_signer.py -n "3rd Party Mac Developer Application" sign AcrobatPro.mobileconfig AcrobatProSigned.mobileconfig

2、加密.mobileconfig文件

./profile_signer.py -n "3rd Party Mac Developer Application" encrypt AcrobatPro.mobileconfig AcrobatProEnc.mobileconfig

3、簽名且加密.mobileconfig文件

./profile_signer.py -n "3rd Party Mac Developer Application" both AcrobatPro.mobileconfig AcrobatProBoth.mobileconfig

"3rd Party Mac Developer Application"為你的證書在鑰匙串中的全名,選擇證書=>顯示簡介=>復(fù)制常用名稱加上引號即可,比如

"iPhone Developer: jakey.shao xxxx@xxx.com"

"iPhone Distribution: Skyfox Network Technology Co., Ltd."

或者終端執(zhí)行命令:security find-identity -p codesigning -v

可獲得所有的證書

方法四:利用系統(tǒng)自帶命令簽名(證書一定在鑰匙串中是信任的)

特別推薦此方法,簡單暴力

1、打開終端,執(zhí)行命令:security find-identity -p codesigning -v

可查看所有證書

2、簽名描述文件

終端執(zhí)行命令:

/usr/bin/security cms -S -N "iPhone Distribution: Skyfox Network Technology Co., Ltd." -i /Users/jakey/Desktop/udid_unsigned.mobileconfig -o /Users/jakey/Desktop/udid_signed.mobileconfig

方法五:ruby腳本簽名

ruby簽名腳本

通過上述任何一個方法,都會得到一個已經(jīng)簽名且驗證有“已驗證”字樣的.mobileconfig文件,如:


按照上述流程操作完成后得到一個有“尚未驗證”紅色字體的.mobileconfig文件可能原因是選擇的簽名證書已經(jīng)過期或者失效,刪除該證書重新添加證書再重新操作一遍即可,或者直接點擊該紅色字體查看具體原因

最后補充一點,這篇文章寫的比較沖忙,純屬個人學(xué)習(xí)參考,需要了解更多超級簽名的可以查看上一篇文章

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容