Java异常客户端身份验证TLS:密码不能为null

Java异常客户端身份验证TLS:密码不能为null,java,ssl,passwords,keystore,ejbca,Java,Ssl,Passwords,Keystore,Ejbca,我编写此代码是为了与ejbca(JBoss 5.1.0.GA-jdk6和ejbca 4.0.10以及openjdk-6-jdk)服务器通信: 但我有一个例外: Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://ejbca05:8443/ejbca/ejbcaws/ejbcaws?wsdl. It failed with: Got java.

我编写此代码是为了与ejbca(JBoss 5.1.0.GA-jdk6和ejbca 4.0.10以及openjdk-6-jdk)服务器通信:

但我有一个例外:

Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://ejbca05:8443/ejbca/ejbcaws/ejbcaws?wsdl. It failed with: 
    Got java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext) while opening stream from https://ejbca05:8443/ejbca/ejbcaws/ejbcaws?wsdl.
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:173)
..........
.......
Caused by: java.security.UnrecoverableKeyException: Password must not be null
    at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:124)
    at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:55)
    at java.security.KeyStore.getKey(KeyStore.java:792)
密钥库是在jks中转换的superadmin.p12…我也尝试过使用ejbca或keytool创建的其他密钥库,但我得到了相同的错误。
有人知道为什么吗?

使用此代码似乎有效

String urlstr = "https://ejbca05.prv:8443/ejbca/ejbcaws/ejbcaws?wsdl";
        System.setProperty("javax.net.ssl.trustStore","C:/Users/l./Downloads/truststore.jks");
        System.setProperty("javax.net.ssl.trustStorePassword","provae");
        System.setProperty("javax.net.ssl.keyStore","C:/Users/l./Downloads/superadmin.p12");
        System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
        System.setProperty("javax.net.ssl.keyStorePassword","provae");
也许将p12转换为jks密钥库工作不正常

编辑:使用此命令可以转换到jks

keytool -importkeystore -srckeystore [MY_FILE.p12] -srcstoretype pkcs12
 -srcalias [ALIAS_SRC] -destkeystore [MY_KEYSTORE.jks]
 -deststoretype jks -deststorepass [PASSWORD_JKS] -destalias [ALIAS_DEST]

看起来属性设置错误

错误:

System.setProperty("javax.net.sslews.keyStorePassword","provae"); 
System.setProperty("javax.net.ssl.keyStorePassword","provae"); 
正确答案:

System.setProperty("javax.net.sslews.keyStorePassword","provae"); 
System.setProperty("javax.net.ssl.keyStorePassword","provae"); 

密钥库和信任库不应使用相同的文件。您的代码无法编译。