うっかりdebug用に署名したapkをリリース用に署名し直す方法

  • 27
    いいね
  • 0
    コメント
この記事は最終更新日から1年以上が経過しています。

こんな感じのdebug用に署名されたapkがあるとするじゃろ

$ jarsigner -verify -verbose -certs app.apk.debug_signed

sm    2046796 Thu Jul 04 20:40:04 JST 2013 classes.dex

      X.509, CN=Android Debug, O=Android, C=US
      [certificate is valid from 10/17/12 10:03 AM to 10/10/42 10:03 AM]

       37164 Thu Jul 04 20:40:04 JST 2013 META-INF/MANIFEST.MF
       37217 Thu Jul 04 20:40:04 JST 2013 META-INF/CERT.SF
         776 Thu Jul 04 20:40:04 JST 2013 META-INF/CERT.RSA

  s = signature was verified 
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

jar verified.

( ^ω^)
⊃zipコマンドで…⊂

$ zip -d app.apk.debug_signed 'META-INF/*'
deleting: META-INF/MANIFEST.MF
deleting: META-INF/CERT.SF
deleting: META-INF/CERT.RSA

( ^ω^)
≡⊃署名を消すじゃろ⊂≡

$ jarsigner -verify -verbose -certs app.apk.debug_signed

  s = signature was verified 
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

no manifest.
jar is unsigned. (signatures missing or not parsable)

( ^ω^)
≡⊃こんなkeystoreを使って…⊂≡

$ keytool -v -list -keystore ~/.android/release.keystore
Enter keystore password:  

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entries

Alias name: release
Creation date: Jan 1, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Jhon Doe, OU=App Division, O=Example, L=Suginami, ST=Tokyo, C=81
Issuer: CN=Jhon Doe, OU=App Division, O=Example, L=Suginami, ST=Tokyo, C=81
Serial number: deadbeef
Valid from: Tue Jan 1 11:22:33 JST 2013 until: Sat Jan 1 11:22:33 JST 2050
Certificate fingerprints:
     MD5:  DE:AD:BE:EF:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
     SHA1: AB:AD:BA:BE:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
     Signature algorithm name: SHA1withRSA
     Version: 3


*******************************************
*******************************************


( ^ω^)
≡⊃jarsignerで署名して…⊂≡

$ jarsigner -verbose -keystore ~/.android/release.keystore app.apk.debug_signed release
Enter Passphrase for keystore: 
   adding: META-INF/MANIFEST.MF
   adding: META-INF/XCERT.SF
   adding: META-INF/XCERT.RSA
  signing: assets/anan.m4a
<<snip>>
  signing: res/drawable-xhdpi/icon.png
  signing: res/drawable-xxhdpi/icon.png
  signing: classes.dex

( ^ω^)
⊃zipalignで整列⊂

$ ~/Applications/android-sdks/tools/zipalign -f -v 4 app.apk.debug_signed app.apk
Verifying alignment of fantasistadoll.apk (4)...
      50 META-INF/MANIFEST.MF (OK - compressed)
   12891 META-INF/XCERT.SF (OK - compressed)
   25965 META-INF/XCERT.RSA (OK - compressed)
   27104 assets/anan.m4a (OK)
<<snip>>
26960572 res/drawable-xhdpi/icon.png (OK)
26982608 res/drawable-xxhdpi/icon.png (OK)
27023811 classes.dex (OK - compressed)
Verification succesful

_人人人人人人人人人人人人_
> リリース用に署名完了!! <
 ̄^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄