bubblewrap icon indicating copy to clipboard operation
bubblewrap copied to clipboard

bubblewrap doesn’t set the password for the key

Open googol7 opened this issue 3 years ago • 3 comments

Describe the bug

When creating a new TWA bubblewrap doesn’t set the password for the key anymore.

To Reproduce

Steps to reproduce the behavior:

  1. bubblewrap init --manifest https://github.com/manifest.json

? Password for the Key Store: ********** ? Password for the Key: ********** keytool Signing Key created successfully

Project generated successfully. Build it by running bubblewrap build

  1. bubblewrap build

? Password for the Key Store: ********** ? Password for the Key: **********

Building the Android App...

results in this error:

cli ERROR Command failed: /Users/phil/.bubblewrap/android_sdk/build-tools/30.0.3/apksigner sign --ks /Users/phil/Daten/Inet/Zemtu/Android/Android/keystores/github.keystore --ks-key-alias github --ks-pass pass:o9cts.sFJe --key-pass pass:6Jma7db-wp --out ./app-release-signed.apk ./app-release-unsigned-aligned.apk Failed to load signer "signer #1" java.io.IOException: Failed to obtain key with alias "github" from /Users/phil/Daten/Inet/Zemtu/Android/Android/keystores/github.keystore. Wrong password? at com.android.apksigner.SignerParams.loadPrivateKeyAndCertsFromKeyStore(SignerParams.java:320) at com.android.apksigner.SignerParams.loadPrivateKeyAndCerts(SignerParams.java:181) at com.android.apksigner.ApkSignerTool.getSignerConfig(ApkSignerTool.java:395) at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:316) at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:88) Caused by: java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption. at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:465) at java.base/sun.security.util.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:90) at java.base/java.security.KeyStore.getKey(KeyStore.java:1057) at com.android.apksigner.SignerParams.getKeyStoreKey(SignerParams.java:375) at com.android.apksigner.SignerParams.loadPrivateKeyAndCertsFromKeyStore(SignerParams.java:288) ... 4 more Caused by: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption. at java.base/com.sun.crypto.provider.CipherCore.unpad(CipherCore.java:975) at java.base/com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1056) at java.base/com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853) at java.base/com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:408) at java.base/com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineDoFinal(PKCS12PBECipherCore.java:440) at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2202) at java.base/sun.security.pkcs12.PKCS12KeyStore.lambda$engineGetKey$0(PKCS12KeyStore.java:406) at java.base/sun.security.pkcs12.PKCS12KeyStore$RetryWithZero.run(PKCS12KeyStore.java:295) at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:400) ... 8 more

On the command line I see: keytool -keypasswd -keystore github.keystore -alias github Keystore-Kennwort eingeben: Neues Schlüsselkennwort für <github>:

Expected behavior: keytool -keypasswd -keystore github.keystore -alias github Keystore-Kennwort eingeben: Schlüsselkennwort für <github> eingeben Neues Schlüsselkennwort für <github>:

Expected behavior

bubblewrap build ? Password for the Key Store: ********** ? Password for the Key: **********

Building the Android App... - Generated Android APK at ./app-release-signed.apk - Generated Android App Bundle at ./app-release-bundle.aab

googol7 avatar Jul 07 '22 16:07 googol7

@googol7

After debug i found that if you provide both Key Store and Key same it will work.

So, mostly there is a bug in creating key. Some where Key Store = Key is happening. I will look at the code as well.

anuragteapot avatar Jul 09 '22 05:07 anuragteapot

@anuragteapot using the same password for key store and key worked for me too (as well as reducing the memory it needed to 512m)

liamrota avatar Jul 15 '22 09:07 liamrota

Can confirm I also needed to provide same passwords for both to build.

shalanah avatar Aug 08 '22 07:08 shalanah

This is actually a duplicate of #693.

andreban avatar Jan 13 '23 22:01 andreban

Closing as a duplicate

andreban avatar Jan 13 '23 22:01 andreban