1,使用singed.jar及系统签名打包
签名证书位于
[root@p-amlogic_20190720_aosp/build/target/product/security]#ll
total 50M
-rwxr-xr-x 1 ops ops 656 2019-08-08 17:13 Android.mk
-rwxr-xr-x 1 ops ops 1.2K 2019-08-08 17:13 media.pk8
-rwxr-xr-x 1 ops ops 1.7K 2019-08-08 17:13 media.x509.pem
-rwxr-xr-x 1 ops ops 1.2K 2019-08-08 17:13 platform.pk8
-rwxr-xr-x 1 ops ops 1.7K 2019-08-08 17:13 platform.x509.pem
-rwxr-xr-x 1 ops ops 3.1K 2019-08-08 17:13 README
-rwxr-xr-x 1 ops ops 1.2K 2019-08-08 17:13 shared.pk8
-rwxr-xr-x 1 ops ops 1.7K 2019-08-08 17:13 shared.x509.pem
-rwxr-xr-x 1 ops ops 1.2K 2019-08-08 17:13 testkey.pk8
-rwxr-xr-x 1 ops ops 1.7K 2019-08-08 17:13 testkey.x509.pem
-rwxr-xr-x 1 ops ops 524 2019-08-08 17:13 verity_key
-rwxr-xr-x 1 ops ops 1.2K 2019-08-08 17:13 verity.pk8
-rwxr-xr-x 1 ops ops 1.5K 2019-08-08 17:13 verity.x509.pem
[root@p-amlogic_20190720_aosp/build/target/product/security]
打包jar位于
[root@p-amlogic_20190720_aosp/prebuilts/sdk/tools/lib]#ll
total 24M
-rwxr-xr-x 1 ops ops 21M 2019-08-08 17:22 d8.jar
-rwxr-xr-x 1 ops ops 969K 2019-08-08 17:22 dx.jar
-rwxr-xr-x 1 ops ops 29K 2019-08-08 17:22 shrinkedAndroid.jar
-rwxr-xr-x 1 ops ops 2.2M 2019-08-08 17:22 signapk.jar
[root@p-amlogic_20190720_aosp/prebuilts/sdk/tools/lib]#
此文上文中的方式
此时,只需要gradlw生成未签名包就可以了
SENRSL:a_displayer senrsl$ ../gradlew clean build assemble --info
然后使用系统签名打包
SENRSL:Downloads senrsl$ java -jar signapk.jar S905X3/platform.x509.pem S905X3/platform.pk8 salto/rainbow/a_displayer/build/outputs/apk/df/release/a_displayer-df-release-unsigned.apk sing_rainbow.apk
SENRSL:Downloads senrsl$
需要注意,build.gradle中需要注释掉 默认签名配置和命名规则,不然打出来的包让人疑惑。。。。
然后突然想到,是不是可以 把 pk8和x509.pem转换成gradle所需要的签名格式,配置到build.gradle中,就不需要手动打了,可以省事很多。
2,系统签名转换app签名
找到了一个现成的库,十几年前的作品。。。。
[root@]#wget https://raw.githubusercontent.com/getfatday/keytool-importkeypair/master/keytool-importkeypair
[root@]#./keytool-importkeypair -k rainbow -p 密码 -pk8 p-amlogic_20190720_aosp/build/target/product/security/platform.pk8 -cert p-amlogic_20190720_aosp/build/target/product/security/platform.x509.pem -alias rainbow
Importing "rainbow" with SHA1 Fingerprint=27:19:6E:38:6B:87:5E:76:AD:F7:00:E7:EA:84:E4:C6:EE:E3:3D:FA
Importing keystore /tmp/keytool-importkeypair.lz67/p12 to rainbow...
Entry for alias rainbow successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
Warning:
<rainbow> uses the MD5withRSA signature algorithm which is considered a security risk.
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore rainbow -destkeystore rainbow -deststoretype pkcs12".
[root@]
一致,都是F9、FA、B8
但这个提示 证书 使用的 MD5withRSA 签名算法存在安全风险。
3,查看apk签名信息
三方复制粘贴公司的:
SENRSL:Downloads senrsl$ keytool -printcert -jarfile /Users/senrsl/Downloads/120_df7b093c4f2f363b7033a6997c7f0614.apk
签名者 #1:
签名:
所有者: CN=WilsonWu, OU=3G Department, O=Tencent, L=Guangzhou, ST=GD, C=CN
发布者: CN=WilsonWu, OU=3G Department, O=Tencent, L=Guangzhou, ST=GD, C=CN
序列号: 4c9215d2
有效期为 Thu Sep 16 21:04:18 CST 2010 至 Mon Feb 01 21:04:18 CST 2038
证书指纹:
MD5: 01:1A:40:26:6C:8C:75:D1:81:DD:D8:E4:DD:C5:00:75
SHA1: B2:E0:B6:4D:75:36:E4:AF:83:63:B4:02:2A:9F:74:72:D5:80:FA:0B
SHA256: 66:89:6A:E0:AA:E4:8B:9E:96:3A:3E:03:4F:A2:CA:81:3C:A2:F6:61:F5:36:19:A9:22:63:A8:A5:C2:E3:F3:88
签名算法名称: SHA1withRSA
主体公共密钥算法: 1024 位 RSA 密钥
版本: 3
SENRSL:Downloads senrsl$
singedapk.jar生成的:
SENRSL:Downloads senrsl$ keytool -printcert -jarfile /Users/senrsl/Downloads/sing_rainbow.apk
签名者 #1:
签名:
所有者: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
发布者: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
序列号: b3998086d056cffa
有效期为 Wed Apr 16 06:40:50 CST 2008 至 Sun Sep 02 06:40:50 CST 2035
证书指纹:
MD5: 8D:DB:34:2F:2D:A5:40:84:02:D7:56:8A:F2:1E:29:F9
SHA1: 27:19:6E:38:6B:87:5E:76:AD:F7:00:E7:EA:84:E4:C6:EE:E3:3D:FA
SHA256: C8:A2:E9:BC:CF:59:7C:2F:B6:DC:66:BE:E2:93:FC:13:F2:FC:47:EC:77:BC:6B:2B:0D:52:C1:1F:51:19:2A:B8
签名算法名称: MD5withRSA (弱)
主体公共密钥算法: 2048 位 RSA 密钥
版本: 3
扩展:
#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 4F E4 A0 B3 DD 9C BA 29 F7 1D 72 87 C4 E7 C3 8F O......)..r.....
0010: 20 86 C2 99 ...
]
[EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US]
SerialNumber: [ b3998086 d056cffa]
]
#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:true
PathLen:2147483647
]
#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 4F E4 A0 B3 DD 9C BA 29 F7 1D 72 87 C4 E7 C3 8F O......)..r.....
0010: 20 86 C2 99 ...
]
]
Warning:
证书 使用的 MD5withRSA 签名算法存在安全风险。
SENRSL:Downloads senrsl$
转换系统签名后生成的:
SENRSL:Downloads senrsl$ keytool -printcert -jarfile /Users/senrsl/android/Project/mtime/salto/rainbow/a_displayer/build/outputs/apk/df/release/rainbow_df_v1.0.0c1_release.apk
签名者 #1:
签名:
所有者: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
发布者: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
序列号: b3998086d056cffa
有效期为 Wed Apr 16 06:40:50 CST 2008 至 Sun Sep 02 06:40:50 CST 2035
证书指纹:
MD5: 8D:DB:34:2F:2D:A5:40:84:02:D7:56:8A:F2:1E:29:F9
SHA1: 27:19:6E:38:6B:87:5E:76:AD:F7:00:E7:EA:84:E4:C6:EE:E3:3D:FA
SHA256: C8:A2:E9:BC:CF:59:7C:2F:B6:DC:66:BE:E2:93:FC:13:F2:FC:47:EC:77:BC:6B:2B:0D:52:C1:1F:51:19:2A:B8
签名算法名称: MD5withRSA (弱)
主体公共密钥算法: 2048 位 RSA 密钥
版本: 3
扩展:
#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 4F E4 A0 B3 DD 9C BA 29 F7 1D 72 87 C4 E7 C3 8F O......)..r.....
0010: 20 86 C2 99 ...
]
[EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US]
SerialNumber: [ b3998086 d056cffa]
]
#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:true
PathLen:2147483647
]
#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 4F E4 A0 B3 DD 9C BA 29 F7 1D 72 87 C4 E7 C3 8F O......)..r.....
0010: 20 86 C2 99 ...
]
]
Warning:
证书 使用的 MD5withRSA 签名算法存在安全风险。
SENRSL:Downloads senrsl$
4,系统安全
看了下p-amlogic_20190720_aosp/build/target/product/security内README的介绍https://source.android.com/devices/tech/ota/sign_builds.html
里面介绍了怎么生成自己的密钥集。。。。
需要生成自己的签名
然后回头看了下之前的几个工厂,都是用的默认签名。。。。
5,keystore转换成pk8、x509.pem
跳到了 os_build.md
2021年12月30日11:47:25
senRsl
2021年08月26日12:02:08
没有评论 :
发表评论