一、获取证书列表的命令行
在通过脚本进行签名的时候,需要在系统的 KeyChain 中获取可用于签名的证书。可以通过命令行获取证书。
$ security find-identity -v -p codesigning
执行结果如下:
1) 300EDAE8339C1F38A5B465C71F0EC416AA6D7115 "iPhone Distribution: Your Company Beijing Software Co.,Ltd"
2) 242DE2190D8E4BB556D3AC69B6A480E90A715FCC "Developer ID Application: Your Company Beijing Software Co.,Ltd"
3) 7AC3E80E806ECCE2DB66FFB6B9DEABFAA0454CE3 "iPhone Developer: 张三 (AGWGSGWQEG)"
4) AA6EB6EC0EA322F91DE2C6ACF93E729235889B0E "Apple Development: 李四 (JDFGHKFGJD)"
5) FB9AC85BB2321918D5070C031F314D279E67C588 "iPhone Distribution: Your Company Shanghai Company Limited"
5 valid identities found
二、提取证书名称列表
如果需要提取证书名称列表,可以配合 sed
命令完成:
#!/bin/bash
# 获取所有可用于签名的证书
certs=$(security find-identity -v -p codesigning)
# 计算有效行数
line_count=$(( $(echo "$certs" | wc -l) - 1 ))
# 删除无用行
certs=$(echo "$certs" | head -n $line_count)
echo "$certs" | sed -r 's/.*"(.*)"/\1/g'
执行结果:
iPhone Distribution: Your Company Beijing Software Co.,Ltd
Developer ID Application: Your Company Beijing Software Co.,Ltd
iPhone Developer: 张三 (AGWGSGWQEG)
Apple Development: 李四 (JDFGHKFGJD)
iPhone Distribution: Your Company Shanghai Company Limited
(完)
网友评论