查找公钥和私钥同时都完整可用的证书,才可以用来对代码进行签名
1,使用security来查看系统中的证书
security find-identity -v -p codesigning
kklocal:Desktop kklocal$ security find-identity -v -p codesigning
- DDCAD3F36A812D64C225CC9813EABC1C22B33542 "iPhone Developer: XXX XXX (XXXXXX)"
- 830E6BA27BC4762ACE1045FBFFFCCCAA8D370FC3 "iPhone Developer: XXX@XXX.com (J7XXXX)"
- 136139D70E652EC13E60CCB0F38DA12EF20C0C81 "iPhone Distribution: XXXXXXXX Co., Ltd"
3 valid identities found
2,重新签名
codesign -f -s 'iPhone Distribution: XXXX XXXX Technology Co., Ltd' KKKAPP.app
3,验证签名
codesign -vv -d KKKAPP.app
codesign --verify KKKAPP.app
Executable=/Users/kklocal/Desktop/KKKAPP.app/Autohome
Identifier=com.autohome.new
Format=app bundle with Mach-O universal (armv7 arm64)
CodeDirectory v=20200 size=221328 flags=0x0(none) hashes=6911+3 location=embedded
Signature size=4732
Authority=iPhone Distribution: XXX XXX XXX Co., Ltd
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Signed Time=2017年5月17日 17:10:51
Info.plist entries=50
TeamIdentifier=9Q2JNSZV5H
Sealed Resources version=2 rules=13 files=2062
Internal requirements count=1 size=192
4,找有用的provision profiles文件
路径
cd ~/Library/MobileDevice/Provisioning\ Profiles
查看内容
security cms -D -i 6544e3c5-39e2-4311-af6f-eeb5e3816c94.mobileprovision
security cms -D -i ccb46e0a-6b63-4166-8132-d47205d0ab62.mobileprovision
5,命令行导入证书
security unlock-keychain -p 111111 ~/Library/Keychains/login.keychain
security list-keychains -s ~/Library/Keychains/login.keychain
security import p12_filepath -k ~/Library/Keychains/login.keychain -P p12_password -T /usr/bin/codesign
security find-identity -p codesigning ~/Library/Keychains/login.keychain
参考
iOS Code Signing 学习笔记
http://www.yl1001.com/article/1901413942094572.htm
代码签名探秘
https://www.objc.io/issues/17-security/inside-code-signing/
中文版本
http://objccn.io/issue-17-2/