Hi there..
i'm trying to connect to a webservice that requires client authentication
with https protocol  but i can't connect because my servlet throws
this exception.

[SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket:
java.net.SocketException: SSL implementation not available;
targetException=java.lang.IllegalArgumentException: Error opening socket:
java.net.SocketException: SSL implementation not available]
 at
org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.ja
va:354)
 at org.apache.soap.rpc.Call.invoke(Call.java:248)
 at TestPagamentiSOAP.doPost(TestPagamentiSOAP.java:62)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)[...]

I have used keyman and in a file called  client3.keystore file i have
imported correctly  private key for client authentication and server
certificate for CA.

a snippet of my code..
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
   Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
   System.setProperty("javax.net.ssl.trustStore","C:\\Documents and
Settings\\mymachine\\Desktop\\client3.keystore");
   System.setProperty("javax.net.ssl.keyStore", "C:\\Documents and
Settings\\mymachine\\Desktop\\client3.keystore");

   String SOAPActionURI = "";
   Call call = createCall();
   call.setMethodName("HelloWorld");
   call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
   call.setTargetObjectURI("urn:Service1");
   Vector params = new Vector();
   Parameter valorePar = new Parameter("valore", int.class, new
Integer(valore), Constants.NS_URI_SOAP_ENC);
   params.addElement(valorePar);
   Parameter nomePar = new Parameter("nome", java.lang.String.class, nome,
Constants.NS_URI_SOAP_ENC);
   params.addElement(nomePar);
   call.setParams(params);
   URL nuovoURL=new
URL("https://serverwithhttps/pagamentiinternet/pagamento.asmx";);
   org.apache.soap.rpc.Response resp = call.invoke(nuovoURL, SOAPActionURI);

    on invoke it throws the exception!!!!!

It's very strange because with the following code everything works great.

   [..]
   System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
   Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

   SSLSocketFactory ssf;
   TrustManagerFactory tmf;
   KeyManagerFactory kmf;
   KeyStore ks;
   FileInputStream fis;
   String pathKeyStore="C:\\Documents and
Settings\\mymachine\\Desktop\\client3.keystore";
   char[] passphrase = "keystore".toCharArray();

   fis=new FileInputStream(pathKeyStore);
   ks = KeyStore.getInstance("JKS");
   ks.load(fis, passphrase);
   tmf = TrustManagerFactory.getInstance("SunX509");
   tmf.init(ks);
   kmf = KeyManagerFactory.getInstance("SunX509");
   kmf.init(ks, passphrase);
   SSLContext ctx = SSLContext.getInstance("TLS");
   ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
   fis.close();

    try {
    URL url = new
URL("https://serverwithhttps/pagamentiinternet/pagamento.asmx";);
    com.sun.net.ssl.HttpsURLConnection connection =
(com.sun.net.ssl.HttpsURLConnection) url.openConnection();
    ssf = ctx.getSocketFactory();
    connection.setSSLSocketFactory(ssf);
    connection.connect();
    System.out.println("Connection OK:" + connection.getURL());
   [...]


   This code works like a sharm,so i'm pretty sure that keystore is correct.
   I'm using:
   jdk 1.2.2
   jsse-1_0_3_01
   apache soap 2.3

   Any hints?
   Tnx in advance.

    Michele




Reply via email to