Reputation: 103
is it possible to change java version of keytool file - .keystore? Our keystore file for signing apks was created under java 7 which is too old as we all know. All our app are developed under newest java version, however because of signing process we still need to keep java 7 on our machine just for signing. Is there any way how to copy entire keystore under newest java version? I already tried e.g.:
keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -v
under java 8 and I got exception:
Unable to initialize, java.io.IOException: DerInputStream.getLength(): Redundant length bytes found
When I run same command under java 7 it works of course.
Already tried:
Oleg's post - gives the same exception as above
Unable to initialize, java.io.IOException: DerInputStream.getLength(): Redundant length bytes found
Import original keystore to new one, using KeyStore Explorer tool, which imported certificate successfully however with changed SHA1 fingerprint.
Create completely new keystore file under Java 7 and list its details using keystool of Java 8 successfully, just to conform that keystore file is somehow broken.
Even tried Oleg's suggestion to open this keystore file under newest Java is not working still Redundant length bytes exception
.
Edit As @Oleg pointed in comment, alias was probably somehow corrupted. So we are not able to use newest Java with this one for signing. So it looks like there is no solution for my issue. Anyway for copying content of one keystore file to another is Oleg's solution is correct.
Upvotes: 4
Views: 5603
Reputation: 6314
Java 8 should have no problem with a keystore
file created by Java 7. You probably have different default keystore types defined by keystore.type
property in java.security
file or some other configuration problem. See here.
Instead of figuring out what the problem is an easy way to solve this would be to use a temporary keystore
with explicit type.
With Java 7 keytool
:
keytool -importkeystore -srckeystore old.keystore -destkeystore temp.keystore.p12 -deststoretype PKCS12
And then with Java 8:
keytool -importkeystore -srckeystore temp.keystore.p12 -srcstoretype PKCS12 -destkeystore new.keystore
Upvotes: 2