-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uninitialzed keystore with Java 8 171/172 and higher #120
Comments
I have investigated this problem, but have come to no solution. With the Java Update 8u171 a new security property has been intorduced http://www.oracle.com/technetwork/java/javase/8u171-relnotes-4308888.html#JDK-8189997 . The input stream is filtered when deserializing a secret key from the keystore. The input must match one of the following types: In the Release Notes to 8u171 Oracle states:
First of all, I do not know how the keys are serialized in the JCT, but I tried to change the filter to allow everything and get it working again.
Description of the errorAs soon as the keystore is to be loaded, the following errors are displayed in the stack trace:
The first Exception:
The second Exception:
The second exception is just a "following error" and will probably disappear as soon as the first exception has been fixed. It is thrown in loadKeystore() in JceKeyStore.java:856, if the keystore failed to load successfully, it tries to create a new keystore. Similar errors on the webhttps://stackoverflow.com/questions/50393533/java-io-ioexception-invalid-secret-key-format-when-opening-jceks-key-store-wi |
Here are some new insights from @simlei and my research:The jdk.serialFilter or the jceks.key.serialFilter can be set with -Djdk.jdk.serialFilter = pattern or -Djdk.jceks.key.serialFilter = pattern. The pattern is described at the very end of your /java/jre/lib/security/java.security file. If you set the filter in this way, an info message will be displayed in the console stating that the filter has been set. This info looks like an error message.
Here’s a nice Link describing the Filter https://docs.oracle.com/javase/10/core/serialization-filtering1.htm#JSCOR-GUID-3ECB288D-E5BD-4412-892F-E9BB11D4C98A. Unfortunately it referes to Java 9. The error message:
It is structured as follows:
The byteinputstream when it is rejected is
Actually, this class should be allowed because the filter was previously set to * (allow all). At the end of |
WorkaroundIf you are using an actual Weekly Build and Windows you have a folder ".jcryptool" in the document library. If you delete this foder once it works with Java 8u170 and higher. The background is that the keystore is saved in the .jcryptool folder. Version 0.9 (last stable version) comes with a key that does not conform to the security policies introduced in Java 8u170. The Weekly Builds no longer provide this key. However, the weekly builds do not overwrite the keystore, so the broken key still exists and continues to cause an exception when loading the keystore. If the folder is deleted, the keystore will be recreated without the broken key and it works. |
The keystore has developed further issues with Java 11, see #149 |
It seems that things have changed once Java 11 with OpenJDK/JRE was introduced and the JAXB issue was resolved. For me, the keystore seems to work now. I have however not have found too much time looking into it and also don't quite remember at which exact point we experienced this issue: Loading the keystore / adding and removing keys? That seems to work now on my machine. Or was it when invoking a certain algorithm? Test with the version from my fork at: https://github.com/simlei/core/releases/tag/v1.0-J11-CH-1 This is the original keystore file that was removed due to the original issue: it goes into ~/Documents/.jcryptool/flexiprovider/ |
I tested the keystore in the version from your fork (https://github.com/simlei/core/releases/tag/v1.0-J11-CH-1). For me, the keystore shows the same error as in previous versions. This are the last lines from the exception:
ReproductionI did the following steps to produce the error:
Current state: JCT runs with Java 11.0.5 and everything seems fine.
Current State: the exception listed above as code snipped is printed to the error log.
This is how i produced the error. I hope you can reproduce it. Testing the old keystore fileNow i tested the old keystore (https://github.com/jcryptool/core/blob/e5215aaff40862c7f199a80b409063dab735d7de/org.jcryptool.crypto.keystore/keystore/jctKeystore.ksf). Current State: No new exceptions in the error log. The old keystore seems to work. In my memory the old keystore does not open at all, so thats an improvement already :) Interestingly there is an "AES, Rijandael" key already stored.
Summary: So the behaviour of the keystore, when trying to show the properties of a key that does not conform the jceks.serialFilter or jdk.serialFilter, is the same with the old and and new keystore file. An improvement is, that the old keystore can be opened :) Testing the "properties" DialogIn the next steps i tested wether the "Properties" dialog works. Therefore i choosed the ElGamal key, because it fits to the serialFilters.
Current State: No new exceptions are shown in the error log after showing the properties of the ElGamal secret key. Summary: The properties Dialog seems to work correct. ConclusioThe keystore works with the old keystore file. I would suggest to replace the new one with the old one, because the old one contains more keys. Unfortunately you can not display all properties of a key that does not conform to jceks.serialFilter or jdk.SerialFilter. The problem does not seem to be fixed on all platforms Hope this will help you @simlei . If you have other scenarios that i should test, just write it in the comments or send me a mail. Best regards, Thorben |
Signed-off-by: Simon Leischnig <simon-jena@gmail.com>
This should do it (see commit above) Could only be released together with the branch from my core/ fork. This is unfortunately still blocked by OSX not starting up with the Java 11 JRE... :( |
Hi @simlei , great news 🎉 Your new product (https://github.com/simlei/core/releases/tag/v1.0-J11-CH-KS-1) works for me.
The product works for the old and new keystore file. :) Best regars, Thorben |
With Java 8 update 171/172 and possibly Java 9/10 the JCT keystore isn't initialized/ working any more. The reason might be the switch from JKS to PKCS12 as keystore format.
The text was updated successfully, but these errors were encountered: