我已经编写了这段代码来与ejbca(JBoss 5.1.0.GA-jdk6和EJBCA 4.0.10。和openjdk-6-jdk)服务器进行通信:

CryptoProviderTools.installBCProvider();
String urlstr = "https://ejbca05:8443/ejbca/ejbcaws/ejbcaws?wsdl";

System.setProperty("javax.net.ssl.trustStore","C:\\Users\\l.\\keystore.jks");
System.setProperty("javax.net.ssl.trustStorePassword","provae);
System.setProperty("javax.net.ssl.keyStore","C:\\Users\\l.\\keystore.jks");
System.setProperty("javax.net.sslews.keyStorePassword","provae");
QName qname = new QName("http://ws.protocol.core.ejbca.org/", "EjbcaWSService");
EjbcaWSService service = null;
try {
    service = new EjbcaWSService(new URL(urlstr),qname);
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    System.out.println("errore nell'url");
}
EjbcaWS ejbcaraws = service.getEjbcaWSPort();


但是我有一个例外:

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创建的其他密钥库,但我遇到相同的错误。
有人知道为什么吗?

最佳答案

看起来该属性设置有误

错误:

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


正确的一个:

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

09-30 11:11