Android 从 apk 获取证书详细信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11361452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:10:13  来源:igfitidea点击:

Getting certificate details from an apk

androidcertificatesigning

提问by Ravi Vyas

How do i go about getting the details of the certificate an apk was signed with. I have a bunch of apks signed with different certificate and I am trying to group them based on their certificate.

我如何获取与 apk 签名的证书的详细信息。我有一堆用不同证书签名的apk,我试图根据他们的证书对它们进行分组。

I can get the certificate expiry details using the jarsigner and complete my task but I was curious if I can get any more details or extract the public key ( I believe it stored in META-INF/cert.RSA but its not readable )

我可以使用 jarsigner 获取证书到期详细信息并完成我的任务,但我很好奇是否可以获得更多详细信息或提取公钥(我相信它存储在 META-INF/cert.RSA 但它不可读)

回答by Yury

Try the following:

请尝试以下操作:

openssl pkcs7 -inform DER -in CERT.RSA -noout -print_certs -text

回答by diptia

unzip -p Name-of-apk.apk META-INF/CERT.RSA | keytool -printcertis what I used .

unzip -p Name-of-apk.apk META-INF/CERT.RSA | keytool -printcert是我用的。

It produces information such as the owner , issuer , serial number , valid through, certificate finger prints , signature algorithms and version .

它产生诸如所有者、发行者、序列号、有效通过、证书指纹、签名算法和版本等信息。

回答by eyecatchUp

Based on the existing answers, here's the command line for on-the-fly usage of openssl(unzip & pipe the cert instead of defining an -infileoption):

基于现有的答案,这里是即时使用的命令行openssl(解压缩和管道证书,而不是定义一个-infile选项)

unzip -p App.apk META-INF/CERT.RSA |openssl pkcs7 -inform DER -noout -print_certs -text

回答by Randy Sugianto 'Yuku'

The easiest of all:

最简单的:

keytool -printcert -jarfile file.apk

This also works for Android App Bundles (.aab)

这也适用于 Android App Bundle (.aab)

回答by Ewoks

without unpacking you can use ApkSigner from Android SDK and following:

无需解包,您就可以使用 Android SDK 中的 ApkSigner 和以下内容:

apksigner.jar verify --print-certs myApplication.apk