10

I am unable to open my existing keystore file in Android Studio or use the jarsigner from the command line.

In both cases the error message is:

java.security.cert.CertificateException: Unable to initialize, java.io.IOException: DerInputStream.getLength(): Redundant length bytes found

See screenshot:
Android Studio

Apparently this was an issue that should be fixed with JDK8_131 but does not work for me. (We are all using OSX)

I also get the same error on travis. (See "Update" section below.)

I found another SO question (Signing android app throws IOException: Redundant length bytes found) where they converted the .pkc12 file to .keystore but we are already using .keystore


UPDATE

I found that the build also started failing on travis because they are moving builds to their new distro trusty which downloads the newest JDK whereas precise used JDK7 by default. Adding dist: precise to the top of the .travis.yml file works for now but this is definitely not a permanent solution.

Can we only hope for a JDK update that fixes the issue or is there a way to remove the redundant length bytes from the keystore?

Community
  • 1
  • 1
JDurstberger
  • 4,127
  • 8
  • 31
  • 68

3 Answers3

2

I also got the same error and I fixed it by following Solution 1 below. you can try Solution 1 to resolve it. Else follow the other Solutions.

Solution 1

Updating JDK from 7 to 8

Solution 2

You can run the following command to list the content of your keystore file:

keytool -list -keystore .keystore

If you are looking for a specific alias, you can also specify it in the command:

keytool -list -keystore .keystore -alias foo

If the alias is not found, it will display an exception:

 keytool error: java.lang.Exception: Alias does not exist

Solution 3

In order to get all the details I had to add the -v option

keytool -v -list -keystore <FileName>.keystore

It will surely help you to solve the error or you can get the contents of your keystore and can generate a new keystore of your app.

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
sugansoft
  • 1,227
  • 8
  • 26
  • sugansoft i agree your answer... great i was looking for long. but simply its fixed and saved my time .... – Gowtham Aug 05 '17 at 05:42
  • Sorry but this does not work. First of all the issue occured when we updated to JDK8. Second `keytool` is the tool that gets invoked by Android Studio. So when using `keytool` I get exactly the same errors. – JDurstberger Aug 06 '17 at 17:31
0

We were able to work around this in the end by using to Google Play App Signing.

We used a machine with JDK 7 to follow all the steps as described in the App Signing tutorial.

We then created the new keystore with a JDK9 machine.

JDurstberger
  • 4,127
  • 8
  • 31
  • 68
  • 2
    what steps did you do exactly? i have the same issue. thanks – Jun Mar 18 '20 at 06:47
  • 1
    I have yet to take this step because the process is irreversible once initiated however I may be going this direction very soon. – DevinM Jul 20 '21 at 17:57
0

I had exactly same issue and none of the solutions worked.

I finally got it working by upgrading to Google's new app signing by uploading the private key generated with pepk tool and asked their support to reset the upload key.

Jun
  • 3,422
  • 3
  • 28
  • 58
  • I have exactly the same issue too, but your solution does not work for me : pepk tool produces exactly same error "Redundant length bytes found". Did you do something to get pepk work? – Teckel Cruel Dec 28 '21 at 23:07