How to Sign Android APK or Zip Files

How to Sign Android APK or Zip Files

Home » Information Technology » Programming » Android » How to Sign Android APK or Zip Files




0digg

When publishing an application or a custom rom  you need to sign the .apk or .zip files with a certificate using a private key. The Android system uses the certificate to identify the author of an application and establish trust relationship between applications. The classic way of doing this was to use keytool then sign it with  jarsigner. In this tutorial i’ll explain an alternative method which is relatively easy to use for most people  using a tool called SignApk.jar.

SignApk.jar is a tool included with the Android platform source bundle, you can download it from here. To use SignApk.jar you have to create a private key with it’s corresponding certificate/public key. To create private/public key pair, you can use Openssl. Openssl is relatively easy to use under unix/linux system. For Windows user, you can download Windows version of Openssl here.

How to create private/public key pair using openssl (windows version)

  • Download openssl package from link given above
  • Extract it anywhere on your drive (eg. C:\openssl)
  • Within openssl directory type (use cmd tool):

    - openssl genrsa -out key.pem 1024
    - openssl req -new -key key.pem -out request.pem
    - openssl x509 -req -days 9999 -in request.pem -signkey key.pem -out certificate.pem
    - openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt

How to sign apk or zip files using SignApk.jar:

  • Download SignApk.rar from link given above
  • Extract it  anywhere on your drive (eg. c:\SignApk)
  • If you don’t have java installed, download and install it.
  • Copy certificate.pem and key.pk8 into your extracted SignApk directory
  • Within SignApk directory type:

    java -jar signapk.jar certificate.pem key.pk8 your-app.apk  your-signed-app.apk

    OR

    java -jar signapk.jar certificate.pem key.pk8 your-update.zip your-signed-update.zip

Note:

If you don’t want to create your own public/private key pair, you can use test key included in SignApk.rar.

Reference:

android-dls.com


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值