1. Sign the APK with the platform key
1.1. Go to <android_source_path>/build/target/product/security and locate the "platform.pk8" and "Platform.x509.pem" system keys.
1.2. Enter <android_source_path>/build/tools/signapk to find Signapk.java, execute Javac compile to Signapk.class
1.3. Run the command Java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk
At this point, complete.
2. Supplement to 1:
There are many pairs of keys under <android_source_path>/build/target/product/security, such as the following:
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/[email Protected] '
Development/tools/make_key platform '/c=us/st=california/l=mountain view/o=android/ou=android/cn=android/[email Protected] '
Development/tools/make_key shared '/c=us/st=california/l=mountain view/o=android/ou=android/cn=android/[email Protected] '
Development/tools/make_key Media '/c=us/st=california/l=mountain view/o=android/ou=android/cn=android/[email Protected] '
The following standard test keys is currently included:
TestKey--a generic key for packages that does not otherwise specify a key.
Platform-a test key for packages that is part of the core platform.
GKFX-a test key for things that is shared in the home/contacts process.
Media-a test key for packages that is part of the media/download system.
These test keys is 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. Supplement to 3:
Before you perform the third-step command, create a new folder, such as the following structure, under your current working folder: com.android.signapk, and then place the signapk generated by the second-step compilation into the folder. Or you can delete the Signapk.java package declaration and then perform the Javac compilation.
Command Java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk
Not only can the APK file be re-signed, but also the entire zip file can be re-signed, including ROM files.
This content belongs to csdn blog blogger Sodino all
Reprint Please specify Source:http://blog.csdn.net/sodino/archive/2010/11/17/6016706.aspx