[macOS]_[Shell]_[获取App的签名证书有效期]

场景

  1. 在进行 macOS开发时, 一般都需要对 app 进行签名,而我们发布产品后,测试如何查看app是否已经签名,证书是否正确,证书的有效期到哪天?我们右键appGet Info并没有签名和证书信息。

说明

  1. 判断一个app是否签名可以通过codesign命令进行获取; 会输出签名的app信息,没有证书有效期和证书名称。
codesign -dvvv /Applications/iTunes.app

输出

Executable=/Applications/iTunes.app/Contents/MacOS/iTunes
Identifier=com.apple.iTunes
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=144720 flags=0x2000(library-validation) hashes=7227+5 location=embedded
Hash type=sha1 size=20
CDHash=590903fd37dbc8c4bb2d9bd6bbe633057ca56e65
Signature size=4105
Authority=Software Signing
Authority=Apple Code Signing Certification Authority
Authority=Apple Root CA
Info.plist entries=38
TeamIdentifier=243LU875E5
Sealed Resources version=2 rules=13 files=7276
Internal requirements count=1 size=64

sign.sh

  1. 获取一个app的签名证书,可以通过几条命令组合.以下内容另存位sign.sh之后通过命令行运行。
echo 使用说明: sh sign.sh App的绝对路径 如:/System/Applications/Mail.app
if  [ -n "$1" ]; then
	echo "[$1]"
	mkdir test-1
	cd test-1
	codesign --display --extract-certificates "$1"
	qlmanage -c public.x509-certificate -p codesign*
	cd ..
	rm -fr test-1
else
	echo "请输入App的绝对路径!!!"
fi

运行成功后会弹出一个截图:
在这里插入图片描述

参考

Bash shell if 语法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Peter(阿斯拉达)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值