1 Reply Latest reply on Jun 9, 2006 11:27 AM by 843833

    URGENT !! error accessing webservices via SSL

    843833
      Hi all!


      First of all, I am a newbie in webservices and SSL. :-)

      I have a remote webservice to acess from java and get a message. I do not need to send any parameters, only get a String.

      I have de client certificate ( .pfx).

      I got the BouncyClaster lib.


      PLEASE, take a llok ate the code and the exception stack trace below and let me know where I am doing the wrong thing




      JAVA CODE
      ###############################
      import java.security.Security;
      import java.util.List;
      import javax.xml.namespace.QName;
      import org.apache.axis.client.Call;
      import org.apache.axis.client.Service;

      public class WSCall {

      public static void main(String[] args) {
      Service service = new Service();
      Call call;
      List rtnValues;
      try {
      Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
      System.setProperty("javax.net.ssl.keyStore", "D:\\MY_CERTIFICATE.PFX");

      System.setProperty("javax.net.ssl.keyStorePassword", "");
      System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
      System.setProperty("javax.net.ssl.trustStore", "D:\\certificadoACRaiz.cer");
      System.setProperty("javax.net.ssl.trustStorePassword", "");

      System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");

      call = (Call)service.createCall();
      call.setTargetEndpointAddress(new java.net.URL("https://WSURL"));
      call.setOperationName(new QName("http://URL", "MYOPERATIONNAME"));
      call.setReturnType(org.apache.axis.Constants.XSD_STRING);

      call.addParameter("testParam",
      org.apache.axis.Constants.XSD_STRING,
      javax.xml.rpc.ParameterMode.IN);
      call.invoke(new Object[] { "" });

      rtnValues = call.getOutputValues();

      System.out.println("WS return : " + rtnValues.get(0).toString());

      } catch (Exception ex) {

      System.out.println(ex.getCause());
      System.out.println(ex.getMessage());
      ex.printStackTrace();

      } // end catch

      }

      }

      ################################
      D:\>javac WSCall.java

      D:\>java WSCall
      java.net.SocketException: Default SSL context init failed: / by zero
      ; nested exception is:
      java.net.SocketException: Default SSL context init failed: / by zero
      AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
      faultSubcode:
      faultString: java.net.SocketException: Default SSL context init failed: / by zero
      faultActor:
      faultNode:
      faultDetail:
      {http://xml.apache.org/axis/}stackTrace:java.net.SocketException: Default SSL context init failed:
      at javax.net.ssl.DefaultSSLSocketFactory.createSocket(DashoA12275)
      at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
      at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
      at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
      at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
      at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
      at org.apache.axis.client.Call.invoke(Call.java:2767)
      at org.apache.axis.client.Call.invoke(Call.java:2443)
      at org.apache.axis.client.Call.invoke(Call.java:2366)
      at org.apache.axis.client.Call.invoke(Call.java:1812)
      at WSCall.main(WSCall.java:32)

      {http://xml.apache.org/axis/}hostname:BESAO000667

      java.net.SocketException: Default SSL context init failed: / by zero
      at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
      at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
      at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
      at org.apache.axis.client.Call.invoke(Call.java:2767)
      at org.apache.axis.client.Call.invoke(Call.java:2443)
      at org.apache.axis.client.Call.invoke(Call.java:2366)
      at org.apache.axis.client.Call.invoke(Call.java:1812)
      at WSCall.main(WSCall.java:32)
      Caused by: java.net.SocketException: Default SSL context init failed: / by zero
      at javax.net.ssl.DefaultSSLSocketFactory.createSocket(DashoA12275)
      at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
      at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
      at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
      at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
      ... 10 more
      ########################

      thanks a lot