r0adkll / sign-android-release

A GitHub action to sign an APK or AAB
MIT License
362 stars 137 forks source link

Previously working Action now failing with java.io.IOException: Short read of DER length #61

Open yuriykulikov opened 2 years ago

yuriykulikov commented 2 years ago

Hello, I have a GitHub action which was working fine for quite some time. Recently I have noticed that signing the app fails sometimes with this exception:

/usr/bin/cp app/build/outputs/apk/develop/release/app-develop-release-unsigned.apk app/build/outputs/apk/develop/release/app-develop-release-unsigned-aligned.apk
/usr/local/lib/android/sdk/build-tools/29.0.3/apksigner sign --ks app/build/outputs/apk/develop/release/signingKey.jks --ks-key-alias  --ks-pass pass: --out app/build/outputs/apk/develop/release/app-develop-release-unsigned-signed.apk app/build/outputs/apk/develop/release/app-develop-release-unsigned-aligned.apk
Failed to load signer "signer #1"
java.io.IOException: Short read of DER length
    at java.base/sun.security.util.DerInputStream.getLength(DerInputStream.java:588)
    at java.base/sun.security.util.DerValue.init(DerValue.java:390)
    at java.base/sun.security.util.DerValue.<init>(DerValue.java:331)
    at java.base/sun.security.util.DerValue.<init>(DerValue.java:344)
    at java.base/sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1[996](https://github.com/yuriykulikov/AlarmClock/runs/6041863318?check_suite_focus=true#step:6:996))
    at java.base/sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:222)
    at java.base/java.security.KeyStore.load(KeyStore.java:1479)
    at com.android.apksigner.SignerParams.loadKeyStoreFromFile(SignerParams.java:353)
    at com.android.apksigner.SignerParams.loadPrivateKeyAndCertsFromKeyStore(SignerParams.java:239)
    at com.android.apksigner.SignerParams.loadPrivateKeyAndCerts(SignerParams.java:181)
    at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:277)
    at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:83)
Error: The process '/usr/local/lib/android/sdk/build-tools/29.0.3/apksigner' failed with exit code 2

Example run: https://github.com/yuriykulikov/AlarmClock/runs/6041847468?check_suite_focus=true

My configuration is:

      - name: Sign develop APK
        uses: r0adkll/sign-android-release@v1
        # ID used to access action output
        id: sign_develop_app
        with:
          releaseDirectory: app/build/outputs/apk/develop/release
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}

What could be the problem?

ehcorrea commented 2 years ago

I'm having the same problem. I tried to upgrade the version to 30.0.2, but without success

edit: I solved sending the correct secret key

vladimirevstratov commented 2 years ago

Check for right secrets in repository - you should add secret with base 64 key

ghost commented 10 months ago

Check for right secrets in repository - you should add secret with base 64 key

What is the format? Should it be BEGIN/END PGP MESSAGE or BEGIN/END CERTIFICATE? Can this occur with an incorrect password?