0

My code to invoke EJBCA service is as below

CryptoProviderTools.installBCProvider();
String keyStorePath ="C:/softwares/ejbca/ejbca_ce_6_2_0/p12/superadmin.p12";
String password = "ejbca";
final String urlstr = "https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl";
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");

System.setProperty("javax.net.ssl.keyStore", keyStorePath);
System.setProperty("javax.net.ssl.keyStorePassword", password);

System.setProperty("javax.net.ssl.trustStore", "C:/softwares/ejbca/ejbca_ce_6_2_0/p12/truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

final Provider tlsProvider = new TLSProvider();
Security.addProvider(tlsProvider);
Security.setProperty("ssl.TrustManagerFactory.algorithm", "AcceptAll");
Security.setProperty("ssl.KeyManagerFactory.algorithm", "NewSunX509");

final QName qname = new QName("http://ws.protocol.core.ejbca.org/", "EjbcaWSService");

final EjbcaWSService service = new EjbcaWSService(new URL(urlstr), qname);
ejbcaraws = service.getEjbcaWSPort(); 

This program works smoothly in standalone but fails with below error in web application:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl. It failed with: Got Software caused connection abort: recv failed while opening stream from https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl.

I tried searching other topics but I did not get concrete solution. Could you please advice how to rectify this issue?

user207421
  • 305,947
  • 44
  • 307
  • 483
Kedar
  • 29
  • 1
  • 7
  • @EJP : I am doing https connection so May I face this issue because of bad certificate ? Initially I was connecting to remote EJBCA server and got this error so I thought of deploying EJBCA locally. Now I am still facing the same issue despite having EJBCA client (my web application) and EJBCA server running locally. When I run 'above code' as stand alone java program it runs and produces the required output but my web application is not able to connect (to EJBCA local server) using same code. I checked ping which is working fine with both localhost and 127.0.0.1.Could you please advice? – Kedar Aug 08 '15 at 18:28
  • I have *already* advised, in the duplicated question. That's why it's a duplicate. It has nothing whatsoever to do with certificates, SSL, EJBCA, Web services, J2EE, Java, or HTTPS. It has to do with exactly and only what my answer in the duplicated question says, which in turn is quoted from Microsoft. – user207421 Aug 10 '15 at 22:51
  • I initialized TrustManagerFactory and KeyManagerFactory. I set these TMF and KMF in newly created "TLS" SSLContext. Finally I set DefaultSSLSocketFactory of HttpsURLConnection with SocketFactory of new SSLContext. Now it is working fine. – Kedar Aug 13 '15 at 00:06

0 Answers0