keytool、jarsigner 均是jdk提供的工具,JDK下载
使用keytool命令生成
keytool -genkeypair -dname "cn=Mark Jones, ou=Java, o=Oracle,c=US" -alias business -keypass 123456 -keystore d:\genkey.jks -storepass 123123 -validity 1200
将会生成签名文件d:\genkey.jks
,有效期1200
个月,别名business
,密钥库的密码123123
,business
的密码123456
使用IDE生成,IntellJ的生成截图如下
本文地址 http://blog.csdn.net/CSqingchen/article/details/78228933
keytool -list -v -keystore genkey.jks
需要用到之前生成签名文件的密钥库的密码123123
keytool -list -v -keystore genkey.jks
输入密钥库口令:
密钥库类型: JKS
密钥库提供方: SUN
您的密钥库包含 1 个条目
别名: business
创建日期: 2017-10-13
条目类型: PrivateKeyEntry
证书链长度: 1
证书[1]:
所有者: CN=Mark Jones, OU=Java, O=Oracle, C=US
发布者: CN=Mark Jones, OU=Java, O=Oracle, C=US
序列号: 510b8a47
有效期开始日期: Fri Oct 13 15:18:36 CST 2017, 截止日期: Wed Apr 11 15:18:36 CST 2018
证书指纹:
MD5: B0:F8:85:EF:57:57:17:4F:42:CA:12:4C:E9:04:F7:B4
SHA1: 9A:40:81:D5:00:2B:83:04:13:67:BC:9F:32:41:C1:9A:D2:F6:9D:E8
SHA256: 2C:8F:40:6D:42:24:8E:0F:E8:88:8B:42:43:3A:FA:49:14:BC:EF:F5:69:8C:67:ED:F1:33:A4:9D:37:7C:A4:27
签名算法名称: SHA1withDSA
版本: 3
扩展:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 68 02 88 E3 69 F1 2F D5 15 BF AC FF A5 FF E1 11 h...i./.........
0010: E2 38 F7 68 .8.h
]
]
*******************************************
*******************************************
jarsigner -keystore D:\genkey.jks -signedjar signed.apk unsigned.apk business
unsigned.apk
用D:\genkey.jks
的business
密匙签名为signed.apk
java -jar signapk.jar platform.x509.pem platform.pk8 signed.apk unsigned.apk
signapk.jar 可以编译Android源码(
mmm build/tools/signapk/
) 得到,源码中位置prebuilts/sdk/tools/lib/signapk.jar
也可能有
platform.x509.pem和platform.pk8在源码目录build/target/product/security/
中
signingConfigs {
config {
storeFile file('../genkey.jks')
storePassword '123123'
keyAlias "business"
keyPassword '123456'
}
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.config
}
}
本文地址 http://blog.csdn.net/CSqingchen/article/details/78228933
将签名后的signed.apk
解压缩到目录signed,会存在签名文件.\signed\META-INF\BUSINESS.DSA
,使用keytool可以查看
keytool -printcert -file D:\signed\META-INF\BUSINESS.DSA
所有者: CN=Mark Jones, OU=Java, O=Oracle, C=US
发布者: CN=Mark Jones, OU=Java, O=Oracle, C=US
序列号: 510b8a47
有效期开始日期: Fri Oct 13 15:18:36 CST 2017, 截止日期: Wed Apr 11 15:18:36 CST 2018
证书指纹:
MD5: B0:F8:85:EF:57:57:17:4F:42:CA:12:4C:E9:04:F7:B4
SHA1: 9A:40:81:D5:00:2B:83:04:13:67:BC:9F:32:41:C1:9A:D2:F6:9D:E8
SHA256: 2C:8F:40:6D:42:24:8E:0F:E8:88:8B:42:43:3A:FA:49:14:BC:EF:F5:69:8C:67:ED:F1:33:A4:9D:37:7C:A4:27
签名算法名称: SHA1withDSA
版本: 3
扩展:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 68 02 88 E3 69 F1 2F D5 15 BF AC FF A5 FF E1 11 h...i./.........
0010: E2 38 F7 68 .8.h
]
]
详细源码 https://gitee.com/chenjimcom/getRawSignature
编译release的APK,安装后可以获取到应用getRawSignature的签名,经过比较同之前生成的keystore的MD5: B0:F8:85:EF:57:57:17:4F:42:CA:12:4C:E9:04:F7:B4
本文地址 http://blog.csdn.net/CSqingchen/article/details/78228933
参考文章
Docs About keytool By Oracle
Android 根据包名,获取应用程序的签名
java keytool证书工具使用小结