termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.32k stars 3.06k forks source link

Make Apksigner generate the keystore #5747

Closed AbdullahM0hamed closed 4 years ago

AbdullahM0hamed commented 4 years ago

Problem description Honestly Apksigner as it currently is, IS a problem - however in goodwill, I'll go ahead and say that the problem is the fact that it doesn't (God knows how much I want to use offensive language here) generate keys - you know, that nice feature we once had which was axed in favour of a ridiculously convoluted process which only generates a keystore which the new apksigner (more offense was omitted from this part for the sake of good will) is only too happy to reject (why thank you @Wetitpig, much appreciated - yeah, maybe I'm gonna regret this later when my anger has died down)

Steps to reproduce 1: Produce a pk8 (or really any other keystore - it's going to reject them all anyway) keystore using openssl (why would I add steps when I can let other strangers come here and also feel pain?) 2: apksigner sign --ks key.pk8 apk or apksigner sign --ks key.pk8 --ks-type PKCS8 [apk] (pick either, failure is guaranteed)

Expected behavior The expected behaviour is apksigner to [omitted swearing] produce a keystore if one doesn't exist. Barring that, the minimum it can [more omitted swearing] do is accept the keys I went through many failed attempts and searches to figure out how to generate. Disappointed this [swearing] was even merged. Makes me want to die.

ghost commented 4 years ago

The expected behaviour is apksigner to [omitted swearing] produce a keystore

Tell this developers of the Android SDK.

apksigner sign --ks key.pk8 apk or apksigner sign --ks key.pk8 --ks-type PKCS8 [apk]

Wrong usage, key != keystore. The built-in help information gives an example the correct command which you need to use. And where's the certificate?

AbdullahM0hamed commented 4 years ago

Damn, at the time I hadn't realised apksigner sign had its own help besides apksigner help (how naive of me) - anyhow changing to (which I assume is correct? As you can see I don't currently have a great record on that front): apksigner sign --key key.pk8 --cert key.pem [apk] which gives me the brilliant error of:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.get(ArrayList.java:437) at java.util.Collections$UnmodifiableList.get(Collections.java:1351) at com.android.apksig.DefaultApkSignerEngine.createV1SignerConfigs(DefaultApkSignerEngine.java:215) at com.android.apksig.DefaultApkSignerEngine.<init>(DefaultApkSignerEngine.java:199) at com.android.apksig.DefaultApkSignerEngine.<init>(DefaultApkSignerEngine.java:62) at com.android.apksig.DefaultApkSignerEngine$Builder.build(DefaultApkSignerEngine.java:1407) at com.android.apksig.ApkSigner.sign(ApkSigner.java:282) at com.android.apksig.ApkSigner.sign(ApkSigner.java:193) at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:340) at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:83) random.user@termux:/sdcard/Download$ apksigner sign --key *pk8 --cert key.pem --cert request.pem --ks-type PKCS8 c*apk Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.get(ArrayList.java:437) at java.util.Collections$UnmodifiableList.get(Collections.java:1351) at com.android.apksig.DefaultApkSignerEngine.createV1SignerConfigs(DefaultApkSignerEngine.java:215) at com.android.apksig.DefaultApkSignerEngine.<init>(DefaultApkSignerEngine.java:199) at com.android.apksig.DefaultApkSignerEngine.<init>(DefaultApkSignerEngine.java:62) at com.android.apksig.DefaultApkSignerEngine$Builder.build(DefaultApkSignerEngine.java:1407) at com.android.apksig.ApkSigner.sign(ApkSigner.java:282) at com.android.apksig.ApkSigner.sign(ApkSigner.java:193) at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:340) at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:83)

Anyhow since this feature shall never be added, there is no point in this issue's existence and I shall close it and continue to suffer.

AbdullahM0hamed commented 4 years ago

As you can see I don't currently have a great record on that front

Oh the irony

ghost commented 4 years ago

Screenshot_20200828-030845_Termux

canandlamp commented 3 years ago

~/.../build/output $ apksigner sign --ks-type PKCS12 --ks /storage/emulated/0/canandlamp-release-key.keystore.new --in app-unsigned-debug.apk --out test-signed.apk Keystore password for signer #1: Exception in thread "main" java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar) at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:362) at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:88)