SecretKeyFactory is broken in JDK 1.6 update 22

If you upgrade JDK to 1.6 update 22 (build 04), the SecretKeyFactory is broken. As a result you will not be able to load any PKCS12 key stores. You will get NoSuchAlgorithmException thrown.

I have reported this issue in the bug database. You can view the bug here. I guess it will take upto a day for this bug to be externally visible, if you don't have a SDN account.

Here is the sample program to reproduce the issue:
public static void main(String[] args) {
        SecretKeyFactory instance = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        System.out.println("Returned instance: " + instance.getAlgorithm());
}

You will get the exception below:
Exception in thread "main" java.security.NoSuchAlgorithmException: PBEWithSHA1AndRC2_40 SecretKeyFactory not available
    at javax.crypto.SecretKeyFactory.<init>(DashoA13*..)
    at javax.crypto.SecretKeyFactory.getInstance(DashoA13*..)
    at main.TestClient.main(TestClient.java:96)

Work around: Until the issue is fixed, revert back to JDK 1.6 update 21. I will update my blog once if I find any fix or work around.

Update on 10/25: Actually I figured one thing: I had update 21 as the project's default JRE in my Eclipse, but tried to run the application using update 22. When I changed the project's default JRE to update 22, I didn't get the error anymore. I am guessing that could be the problem. I am not having the issue any more.

Comments

Erik van Oosten said…
I am running Ubuntu 10.04 and do not see this problem.

Popular posts from this blog

Gotchas with DBCP

A note on Java's Calendar set() method

The mysterious ORA-03111 error