[Android]使用platform密鑰來給apk檔案簽名的命令

來源:互聯網
上載者:User

標籤:android   c   class   blog   code   java   

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/[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 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檔案。

 

 

本文內容歸CSDN部落格博主Sodino全部

轉載請註明出處:http://blog.csdn.net/sodino/archive/2010/11/17/6016706.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.