前提
安装Java JDK并配置好Java环境变量,执行如下命令:
*******$ keytool
如果输出如下内容,则说明Java环境变量配置成功。
Commands:
-certreq Generates a certificate request
-changealias Changes an entry's alias
-delete Deletes an entry
-exportcert Exports certificate
-genkeypair Generates a key pair
-genseckey Generates a secret key
-gencert Generates certificate from a certificate request
-importcert Imports a certificate or a certificate chain
-importpass Imports a password
-importkeystore Imports one or all entries from another keystore
-keypasswd Changes the key password of an entry
-list Lists entries in a keystore
-printcert Prints the content of a certificate
-printcertreq Prints the content of a certificate request
-printcrl Prints the content of a CRL file
-storepasswd Changes the store password of a keystore
查看签名证书指纹
执行如下命令查看签名证书的各种指纹,将keystore替换为自己的签名证书:
******$ keytool -list -v -keystore ~/Downloads/{keystore}
会输出如下信息:
注意:一定要到-v,否则只显示SHA1的指纹信息
查看应用的签名信息
Android应用默认采用MD5码作为应用的签名信息,按如下步骤查看应用的签名信息:
- 查找应用中存储签名文件的路径
******$ tar -tf ./app/dev/debug/my.apk | grep RS
输出如下信息
- 从应用中解压出签名文件
******$ tar -xf ./app/dev/debug/my.apk META-INF/CERT.RSA
- 获取应用的签名信息
******$ keytool -printcert -file META-INF/CERT.RSA
输出如下信息:
其中的MD5码就是应用的签名。
也可以使用openssl查看证书更详细的信息,命令如下:
openssl pkcs7 -inform DER -in CERT.RSA -print_certs -noout -text