为iOS的mobileconfig文件进行签名

本文主要讲,使用苹果开发者证书进行签名达到目的,本文两种方法,一种是刀耕火种的一步步操作,一种使用脚本签名

一.导出苹果证书进行签名

1.从钥匙串(keychain)中导出证书

实用工具->钥匙串访问->选择要导出的证书,导出生成p12文件 InnovCertificates.p12

然后转换成 InnovCertificates.pem 文件

2. p12换成pem格式方法

p12在线转换pem   https://www.sslshopper.com/ssl-converter.html

(证书)cer.p12文件 转cer.pem文件

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

(私钥)key.p12文件转key.pem文件

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

3.下载 Apple Root Certificate 和 Apple Intermediate Certificate

(对于本篇文章 .mobileconfig文件的验证我使用了苹果的以下两个证书.

Apple Root Certificate(苹果根证书)

Apple Application Integration Certificate (苹果应用集成证书 )

你也可以使用这些证书或者苹果提供的其他证书 地址: http://www.apple.com/certificateauthority/

下载的文件中包括证书(cer)和私钥(key)

(在命令行中读取证书,参考链接 info.ssl.com/article.aspx?id=12149)

根据这个文件我们可以解压出来证书.

2. p12换成pem格式方法

p12在线转换pem   https://www.sslshopper.com/ssl-converter.html

(证书)cer.p12文件 转cer.pem文件

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

(私钥)key.p12文件转key.pem文件

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

3.下载 Apple Root Certificate 和 Apple Intermediate Certificate

(对于本篇文章 .mobileconfig文件的验证我使用了苹果的以下两个证书.

Apple Root Certificate(苹果根证书)

Apple Application Integration Certificate (苹果应用集成证书 )

你也可以使用这些证书或者苹果提供的其他证书 地址: http://www.apple.com/certificateauthority/

下载的文件中包括证书(cer)和私钥(key)

(在命令行中读取证书,参考链接 info.ssl.com/article.aspx?id=12149)

根据这个文件我们可以解压出来证书.

解压 Apple Root Certificate证书. 然后解压Apple Intermediate Certificate
openssl x509 -inform DER -outform PEM -in AppleIncRootCertificate.cer -out root.crt.pem
openssl x509 -inform DER -outform PEM -in AppleAAICA.cer -out Intermediate.crt.pem
 
在文本编辑器中打开两个解压出来的文件
复制并且粘贴 Intermediate.crt.pem root.crt.pem的开始位置,保存,然后你的root.crt.pem文件就是两个证书合并的结果
 
4.签名和验证.mobileconfig文件

上边所有文件准备号后,运行命令行工具,运行以下命令

1
openssl smime -sign -in Example.mobileconfig -out SignedVerifyExample.mobileconfig -signer InnovCertificates.pem -certfile root.crt.pem -outform der -nodetach
 
结果就是签名并且验证后的 .mobileconfig文件
 

二.脚本签名

借助于强大的github,找到了一个python脚本进行签名

地址:https://github.com/nmcspadden/ProfileSigner

1.签名一个mobileconfig

profile_signer.py与 mobileconfig 放在同一目录,终端进入目录执行

1
./profile_signer.py -n "3rd Party Mac Developer Application" sign AcrobatPro.mobileconfig AcrobatProSigned.mobileconfig
2.加密一个mobileconfig
1
./profile_signer.py -n "3rd Party Mac Developer Application" encrypt AcrobatPro.mobileconfig AcrobatProEnc.mobileconfig
 
3.签名并且加密一个mobileconfig
1
./profile_signer.py -n "3rd Party Mac Developer Application" both AcrobatPro.mobileconfig AcrobatProBoth.mobileconfig

"3rd Party Mac Developer Application"为你的证书在钥匙串中的全名,选择证书=>显示简介=>复制常用名称加上引号即可,比如

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

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

66911171-EE9C-4DB7-BFCE-6564CC1B4E1A

如果能正确读取到证书,会提示如上图所示,点击允许即可!

转载于:https://www.cnblogs.com/qiaomc/p/6067028.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值