使用platform密钥来给apk文件签名的命令


使用platform密钥来给apk文件签名的命令

http://www.devdiv.com/Android-%E4%BD%BF%E7%94%A8platform%E5%AF%86%E9%92%A5%E6%9D%A5%E7%BB%99apk%E6%96%87%E4%BB%B6%E7%AD%BE%E5%90%8D%E7%9A%84%E5%91%BD%E4%BB%A4-thread-39576-1-1.html


这篇文章可以用来干坏事,请坏人自动走开,好人继续往下看...(感觉自己好天真啊)

1.使用platform密钥对apk进行签名
1.1.进入<Android_Source_Path>\build\target\product\security,找到【platform.pk8】和【platform.x509.pem】系统密钥。
1.2.进入<Android_Source_Path>\build\tools\signapk找到SignApk.java,运行 javac编译成SignApk.class
1.3.执行命令java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk

至此,完成。


2. 对1的补充:
<Android_Source_Path>\build\target\product\security下有多对密钥,详细如下:

The following commands were used to generate the test key pairs:

development/tools/make_key testkey'/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
development/tools/make_key shared '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
development/tools/make_key media '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'

The following standard test keys are currently included:

testkey -- a generic key for packages that do not otherwise specify a key.
platform -- a test key for packages that are part of the core platform.
shared -- a test key for things that are shared in the home/contacts process.
media -- a test key for packages that are part of the media/download system.

These test keys are used strictly in development, and should never be assumed
to convey any sort of validity.When $BUILD_SECURE=true, the code should not
honor these keys in any context.


signing using the openssl commandline (for boot/system images)
--------------------------------------------------------------

1. convert pk8 format key to pem format
% openssl pkcs8 -inform DER -nocrypt -in testkey.pk8 -out testkey.pem

2. create a signature using the pem format key
% openssl dgst -binary -sha1 -sign testkey.pem FILE > FILE.sig

extracting public keys for embedding
------------------------------------
it's a Java tool
but it generates C code
take a look at commands/recovery/Android.mk
you'll see it running $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar

3.对3的补充:
在运行第三步的命令前,请在你当前的工作目录下新建如下结构的文件夹:com.android.signapk,然后将第二步编译生成的 SignApk放入该目录下。或者也可以将SignApk.java的package声明删除后再运行javac编译。

命令java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk

不单可以对apk文件进行重签名,也可以对所有的zip文件进行重签名,包括ROM文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值