• [Android]使用platform密钥来给apk文件签名的命令


    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文件。

    本文内容归CSDN博客博主Sodino 全部

    转载请注明出处: http://blog.csdn.net/sodino/archive/2010/11/17/6016706.aspx

  • 相关阅读:
    如何使页面中的INPUT按指定的顺序移动焦点{转}
    Eclipse把包引入到项目中的方法
    mssqlserver和sqlexpress的区别{转}
    WPF中动态加载XAML中的控件
    修改Eclipse的智能感知设置
    格式化包括字符串, 数字, 日期, 枚举等类型数据的格式化
    ASP.NET身份验证机制membership入门——配置篇(1){转}
    JAVA基础总结{转}
    asp.net mvc的生命周期{转}
    使用开源免费类库在.net中操作Excel{转}
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4045414.html
Copyright © 2020-2023  润新知