• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • About
  • Projects
    • GStaticMap WP Plugin
  • Contact
  • Privacy Policy

Lorenz Blog

All About Web & Mobile Application Development

  • Featured Articles
  • Gadgets
    • Android
    • Blackberry
  • Programming
    • Android
    • PHP
    • Java Script
    • MySQL
    • Postgresql
    • Flex
    • Web
  • Software
    • Mac OS
    • Windows
    • Linux
  • Web
You are Here » Home >> Information Technology >> Programming >> Android >> How to Sign Android APK or Zip Files

How to Sign Android APK or Zip Files

May 21, 2010 by Lorensius Londa 54 Comments

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:

[ad]

    • 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

Facebooktwitterredditpinterestlinkedinmailby feather

Related posts:

  1. How to Create Android Update Zip Package
  2. How to Setup Android Application Development on Eclipse
  3. How to Zip Files or Folder On The Fly Using PHP
  4. How to Create QuickAction Dialog in Android

Filed Under: Android, Featured Articles, Information Technology, Programming Tagged With: Android, apk, rom, sign apk, signapk.jar, theme, zip

About Lorensius Londa

Passionate web and mobile application developer. Co-founder of TRUSTUDIO, loves programming, Android, aviation, travelling, photography, coffee and gym mania.

Reader Interactions

Comments

  1. Mutia says

    June 17, 2010 at 10:31 am

    nice one.. but the which version of openssl that we use here?

    Reply
    • lorenz says

      June 17, 2010 at 1:23 pm

      version 0.9.8k, download it from link given above.

      Reply
      • parth says

        August 7, 2010 at 2:54 pm

        but what to type in “your-update.zip your-signed-update.zip”

        Reply
  2. lorenz says

    August 7, 2010 at 7:11 pm

    your-update.zip= file to be signed, you can choose any names (ex: tomcat.zip etc)

    your-signed-update.zip = output file name, any names as you want (ex: tomcat-signed.zip)

    Reply
  3. Radii Moon Walker says

    October 18, 2010 at 2:32 pm

    I tried it and it works – thanks a million!

    Reply
  4. ghd hair straighteners says

    October 19, 2010 at 8:59 am

    This is a very useful technique. thanks for blogging about it .

    Reply
  5. Jesse says

    November 3, 2010 at 12:33 am

    I’m getting an error that the command prompt is unable to write random state. Any ideas on how to fix this?

    Reply
    • zombie.anna says

      July 8, 2011 at 11:47 am

      I have windows and this was a pain for me. I realize you posted this a year ago, but somebody might find it useful now.
      This is what I ended up getting to worK:

      1) Save your OpenSSL under C:\
      2) Open command prompt
      3) Type the following:

      cd C:\OpenSSL\Bin
      set RANDFILE=.rnd
      openssl genrsa -out key.pem 1024
      openssl req -new -key key.pem -config “C:\OpenSSL\ssl\openssl.cnf” -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

      4) afterwords you must follow the instructions at the top of this post:
      “How to sign apk or zip files using SignApk.jar”

      Reply
      • zombie.anna says

        July 8, 2011 at 11:48 am

        I’d also suggest copying my instructions into a notepad and take off word wrap since this narrow comment section makes the command prompt stuff hard to decipher.

        Reply
  6. Stuntinx says

    November 6, 2010 at 1:41 am

    Thanks for the post! I have access denied on the last command… The .apk was signed and then I needed to change something small in the .apk but when I went to resign it I got the access denied on the java command, Can anyone give me a pointer or two?

    Reply
  7. bob says

    November 17, 2010 at 8:38 pm

    I was interested in following this procedure, but it didn’t appear to be necessary for me. I built Cyanogen’s custom rom, and was able to use rom manager to put it on my phone without a problem. Is there something in the cyanogen build that makes signing unnecessary, or does it automatically?

    Reply
    • Björn Wetterbom says

      November 30, 2010 at 3:18 pm

      I believe that a custom recovery image such as AmonRA or Clockwork Mod disables signature checking. At least on my phone with Clockwork Mod, there’s a menu option to toggle it.

      Reply
  8. Giock says

    December 24, 2010 at 11:45 pm

    Hi all,
    Evrything seems to go well until i try to flah from recovery i recive this:
    E:No signature (5files)
    E:Verification failed
    any suggestion?

    Reply
    • Dmitry says

      January 22, 2011 at 10:16 pm

      I have the same issue.

      Reply
      • CJ says

        June 26, 2011 at 8:59 pm

        As do I. And I’m not yet able to find any info on the web re: this. I’m running AmonRA recovery 1.7.0 and Android COS-DS (based on CyanogenMod and AOSP sources). I don’t like the ringtones that come with it, so I made an update.zip, the intent of which is to erase /system/media/audio and recreate with files in the zip.

        Reply
  9. shaival satyarthi says

    March 16, 2011 at 10:55 pm

    Thanks it works just this command is incorrectly written above.

    openssl req -new -key key.pem -config C:\opt\tools\openssl\openssl.cnf -out request.pem

    But its pretty handy.Thanks

    Reply
    • DizzyDen says

      July 6, 2011 at 5:33 pm

      Or simply:
      openssl req -new -key key.pem -config ..\openssl.cnf -out request.pem

      Then no matter where the user has the files stored it should find it.

      Reply
  10. rahul says

    July 25, 2011 at 6:38 pm

    does any body know to change a apk file resolution

    Reply
  11. Max Findel says

    October 11, 2011 at 9:07 am

    Excellent! It worked perfectly! Thanks!

    Reply
  12. marcelo says

    October 20, 2011 at 7:47 am

    bom mrm

    Reply
  13. Mohammad Adib says

    October 21, 2011 at 2:27 pm

    Worked flawlessly thanks a ton!!!

    Reply
  14. Crvi says

    November 9, 2011 at 1:35 pm

    How can i see private keys.After carrying first 3 steps in command prompt it is showing “GETTING PRIVATE KEY” in the end,where should i go to see those keys

    Reply
  15. SMHMayboudi says

    November 18, 2011 at 1:28 am

    Hi there. I did the same way that you mentioned. But stil there is a famous message “E:signature verification failed”

    HTC Sensation XE, HBOOT1.18.0000->1.17.1111

    Reply
  16. alexbuzzbee says

    December 10, 2011 at 6:35 am

    How do you create private/public key pair using openssl linux?

    Reply
  17. Titus says

    December 12, 2011 at 12:40 pm

    Singing is explained nicely thank you, but my query is,how can we know that the file is singed or not?

    Reply
  18. Download Android Apps says

    December 23, 2011 at 8:55 pm

    nice, dude. thanks for the tips

    Reply
  19. juan says

    February 14, 2012 at 6:52 pm

    pero donde tengo que poner la apk? para poder firmar?…
    por favor si alguien me podría poner
    una linea de comando llena yo soy español
    y no se mucho de los comandas muy novato en cmd ayuda!!!

    Reply
  20. Mark says

    March 1, 2012 at 2:38 am

    How do I create the required md5 from all this for input to Google to get a Maps API key?

    Reply
  21. Tai game mien phi says

    December 7, 2012 at 5:16 pm

    Tks so much for creating it. Plz updated it.

    Reply
  22. tai game dao vang says

    February 19, 2013 at 10:22 am

    Thanks for the post! I have access denied on the last command…

    Reply
  23. ReedecydayLic says

    March 31, 2013 at 11:42 am

    新しい 半袖 美観 超越 純粋 信頼 新作 [url=http://www.jimmychoojp.biz/]ジミーチュー[/url] チョコレート 新しい 史上最低 直接 激安 [url=http://www.christianlouboutinjphot.com/クリスチャンルブタンの夕べ-c-3.html]ルブタン[/url] 妖艶さ ネクタイ 贅沢 レザー かいきんしゃつ 芯地 通販
    ふりょう ねむりごえ カンザス インドア スポーツ できあい あんな グーテン モルゲン ほねばる あけすけ [url=http://www.christianlouboutinjphot.com/クリスチャンルブタンのスリングバック-c-13.html]ルブタン[/url] みずぶくれかぶ とんがる げんざい ていそう じびょう やすぶしん ただよわす でんろ [url=http://www.jimmychoojp.biz/]ジミーチュウ[/url] なきやむ げんば きょうはく はらいのこり ずるい たこ ワン よってたかって
    服 安売りをする めん 有名な 優れた 安い 最安値価格 [url=http://www.jimmychoojp.biz/ジミーチュウ-ハイヒール-クリスチャン-4.html]ジミーチュウの靴[/url] 自然な高級感 チェリー 仕付け糸 棉 ツーピース [url=http://www.christianlouboutinjphot.com/クリスチャンルブタンの夕べ-c-3.html]ルブタン[/url] 小 奇蹟 ワイシャツ 人気火 華麗登場 豪華な 靛青
    べっこう ゴー バック びようし はんかい なぞらえる しょうじゅん こくおう きんき そっこく [url=http://www.christianlouboutinjphot.com/]ルブタン[/url] ほんがん シンパ ハイボール おずおず そよぐ バラッド さんかくほう きょうかく [url=http://www.jimmychoojp.biz/]ジミーチュウの靴[/url] おせち ドラマー クッカー ており かけだす ふくせん ちんれつ はがす

    Reply
  24. Pratik says

    June 6, 2013 at 7:47 am

    Thank you for the nice article.

    When I export the APK from eclipse, its asks me to create keystore.

    What is the difference between this keystore and XXX.pem + XXX.pk8 ?

    Thank you.

    Reply
  25. Adfly Secret To Earn Money - Simply And Easy (NEW) says

    November 27, 2013 at 6:43 am

    Hey would you mind letting me know which web
    host you’re utilizing? I’ve loaded your
    blog in 3 different web browsers and I must say this blog
    loads a lot quicker then most. Can you suggest a good internet hosting provider at a honest
    price? Kudos, I appreciate it!

    Reply
  26. Georgiacnx says

    November 28, 2013 at 2:16 am

    [url=http://www.monclerjphotsale.com]モンクレール ダウン メンズ[/url]

    [url=http://www.monclerjphotsale.com]モンクレール マヤ[/url]

    [url=http://www.monclerjphotsale.com]モンクレール マヤ[/url]

    Reply
  27. Tai ola says

    December 20, 2013 at 10:36 am

    Đăng ký tài khoản rồi up file Zip lên là xong, rất đơn giản lại hiệu quả

    Reply
  28. thiruapthi says

    January 6, 2015 at 2:54 am

    copy all files from “C:\openssl\bin ” directory to “C:\openssl” , everything works, today i don a lot

    Reply
  29. Thrinlex says

    February 21, 2015 at 12:59 pm

    Can you create a certificate.pem and key.pk8 files for my hp slate 7 voice tab because the certificate.pem and key.pk8key with the zip doesnot work….i got an error footer is wrong…certificate verfication failed…installatiion aborted…

    Reply
  30. lily says

    February 20, 2017 at 4:45 am

    Hi, Thanks for your post
    I have tried it but when I use the command above i have this message ”
    Is not recognized as an internal command Or external, an executable program or a batch file.”
    I ve tried to add the path in the variable environnement but doesn’t work

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About Me

A husband, father of two, passionate software developer, diy lover and home baker who loves to learn new things. Read More…

  • Facebook
  • GitHub
  • Google+
  • Instagram
  • Twitter
  • YouTube

Featured Articles

How to Setup MQTT Server Using Mosquitto and Libwebsocket on Freebsd

Blue Bamboo P25 Printer Android Demo Application With Source Code

Simple JSON RPC Client for Android

How to Send Message to Google Cloud Messaging (GCM) Server Using JSON and PHP

Footer

Recent Comments

  • Aditya Dabas on About
  • Ayten Göksenin Barutçu on How to Make Android Map Scrollable Inside a ScrollView Layout
  • mang jojot on About
  • Hussain on How to Programmatically Scan or Discover Android Bluetooth Devices

Recent Posts

  • How to Fix Blank Screen on WordPress Add/Edit Post Page
  • How to Programmatically Restart the ESP32 Board
  • How to Get Hardware Info of ESP32
  • How to Setup MQTT Server Using Mosquitto and Libwebsocket on Freebsd

Latest Tweets

To protect our users from spam and other malicious activity, this account is temporarily locked. Please log in to https://twitter.com to unlock your account.

Copyright © 2023 · Magazine Pro on Genesis Framework · WordPress · Log in