You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by venkatesh <ve...@lasonindia.com> on 2005/04/07 12:08:05 UTC

Getting Exception

Hi Users,
  I'm using Axis1.2 RC2 to connect to .Net webservice. I tried to use wsdl2java to generate .NET webservice's client code. This uses HTTPS. So i included this below line to avoid the certificate validation. It works fine. But it is not working when i tried to call the webservice method with the same certificate validation disable code. It's saying that "SSLHandshakeException:No trusted certificate found" exception. Below is my code to generate client side code.

public static void main(String s[]){
     TrustManager[] trustAllCerts = new TrustManager[]{
             new javax.net.ssl.X509TrustManager() {
                 public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                     return null;
                 }
                 public void checkClientTrusted(
                     java.security.cert.X509Certificate[] certs, String authType) {
                 }
                 public void checkServerTrusted(
                     java.security.cert.X509Certificate[] certs, String authType) {
                 }
             }
         };
     
     try {
      javax.net.ssl.HostnameVerifier myHv = new javax.net.ssl.HostnameVerifier(){
          public boolean verify(String hostName,javax.net.ssl.SSLSession session){
           return true;
          }
         };
            SSLContext sc = SSLContext.getInstance("SSL");
            sc.init(null, trustAllCerts, new java.security.SecureRandom());
            HttpsURLConnection.setDefaultHostnameVerifier(myHv);
            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
        } catch (Exception e) {
        }

        GenerateWSDL wsdl = new GenerateWSDL();
        wsdl.run(s);

    }

Can anybody help me to solve this prob.......


Regards,
Venkatesh P.