Sun Java KeyManagerFactory和空密码 [英] Sun Java KeyManagerFactory and null passwords
问题描述
我们在Sun JRE 1.6中遇到了KeyManagerFactory的问题。我们使用类似于以下内容的代码上传和使用p12格式的证书:
We are having a problem with the KeyManagerFactory in the Sun JRE 1.6. We are using code similar to the following to upload and use a certificate in p12 format:
KeyStore keyStore = KeyStore.getInstance(PKCS12);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(SUN_X509);
InputStream certificateFile = getSSLCertificate();
String certificatePassword = getSSLCertificatePassword();
keyStore.load(certificateFile, certificatePassword);
keyManagerFactory.init(keyStore, certificatePassword);
当证书密码存在时,此代码可正常工作。但是当证书密码为空(因此证书不受密码保护)时,我们会从keyManagerFactory.init行得到除零错误。
This code works correctly when the certificate password exists. But when the certificate password is null (so the certificate is not protected by a password) we get a divide by zero error from the keyManagerFactory.init line.
有谁知道为什么会这样?没有密码就不能使用证书吗?
谢谢
Does anyone know why this is happening? Is it not possible to use a certificate without a password? Thanks
推荐答案
这是一个错误:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id= 6415637
解决方法是设置密码。
这篇关于Sun Java KeyManagerFactory和空密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!