Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

can't use a pfx file with no password in a KeyManagerFactory

910573Jan 12 2012 — edited Jan 13 2012
I have a pfx file which contains a private key and a corresponding self-signed certificate. The pfx file itself is not protected by any password. I can't seem to use this pfx file to initialize a KeyManagerFactory for an SSL connection.

Here's some code which shows what I am trying to do:

InputStream ksStream = ResourceReader.getResourceAsStream("<pfx-file-location-on-file-system>");
char[] password = null; //since the pfx file has no password on it
Keystore keyStore.load(ksStream, password);

KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509", "SunJSSE");
kmf.init(keystore, password);

This fails with this exception:

java.security.UnrecoverableKeyException: Get Key failed: / by zero
at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:270)
at java.security.KeyStore.getKey(KeyStore.java:763)
at com.sun.net.ssl.internal.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:113)
at com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:48)
at javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:239)
at jsse.common.JsseSample.createKeyManagerFactory(JsseSample.java:294)
at jsse.common.JsseSample.createKeyManagerFactory(JsseSample.java:306)
at jsse.server.Simple.runSample(Simple.java:81)
at jsse.server.Simple.main(Simple.java:57)
Caused by: java.lang.ArithmeticException: / by zero
at com.sun.crypto.provider.PKCS12PBECipherCore.a(DashoA13*..)
at com.sun.crypto.provider.PKCS12PBECipherCore.a(DashoA13*..)
at com.sun.crypto.provider.PKCS12PBECipherCore.a(DashoA13*..)
at com.sun.crypto.provider.PKCS12PBECipherCore.a(DashoA13*..)
at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineInit(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:251)
... 8 more

This code works fine if I put a password on the pfx file and then use that password to load the keystore and then use it in the KeyManagerFactory.

My question is: Why can I not use a pfx file that has not password on it?

Thanks,
R.

Edited by: 907570 on Jan 12, 2012 1:01 AM

Edited by: 907570 on Jan 12, 2012 1:18 AM
This post has been answered by sabre150 on Jan 13 2012
Jump to Answer

Comments

843799
Hi there!

Well, try installing java3d in the same directory as ur java(which is c:\jdk1.3.1 for u).

If i am not mistaken, java3d, by default, installs in c:\jdk1.2.2 directory.

U also have 2 set the path and classpath in the autoexec.bat to addr to \bin and \lib sub-directories resp.
843799
OK, this is a known problem with the J3D installer and Windows ME. I (along with many others) have had the same problem. I believe someone came up with a workaround, try searching the forum for previously posted topics. I eventually had to copy the 6 J3D files off of another computer manually.
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 10 2012
Added on Jan 12 2012
4 comments
3,738 views