javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connecti

classic Classic list List threaded Threaded
2 messages Options
YJO
Reply | Threaded
Open this post in threaded view
|

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connecti

YJO
Hi,

I'am accessing a webservice throug a proxy (that requeries authentication) over SSL and I keep getting this message : javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

This is what I do ?

          System.setProperty("javax.net.ssl.keyStore", keystoreUri);
        System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
        System.setProperty("javax.net.ssl.keyStoreType", "JKS");

        System.setProperty( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol" );
       
        System.setProperty("javax.net.ssl.trustStore", truststoreUri);
        System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
       
        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", "<myhost>");
        System.setProperty("http.proxyPort", "80");
        System.setProperty("http.proxyUser", "<myuser>");
        System.setProperty("http.proxyPassword", "<mypasswd>");

        System.setProperty("https.proxySet", "true");
        System.setProperty("https.proxyHost", "<my-host>");
        System.setProperty("https.proxyPort", "443");
        System.setProperty("https.proxyUser", "<myuser>");
        System.setProperty("https.proxyPassword", "<mypasswd>");
        System.setProperty("java.net.debug", "all");


Acessing the url of the webservice via the browser works fine also setting up a communication like here (see below) works fine. Yet the axis API doesn't offer me this to do(or am I wrong).

        try {
        javax.net.ssl.HttpsURLConnection connection = (javax.net.ssl.HttpsURLConnection)new URL("https://gmail.com").openConnection();
        String encoded = new String(org.apache.commons.codec.binary.Base64.encodeBase64(new String("<myuser>:<mypasswd>").getBytes()));
        connection.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
       
        connection.setHostnameVerifier(new HostnameVerifier(){
        public boolean verify(String urlHostName, SSLSession session) {
        return true;
        }
        });

        connection.connect();
        boolean b = connection.usingProxy();
        BufferedInputStream i = new BufferedInputStream(connection.getInputStream());
        StringBuffer sb = new StringBuffer();
            int c = 0;
            while ((c = i.read()) != -1) {
                sb.append((char) c);
            }
                       
        System.out.println("end");
        } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
        } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
    }

Reply | Threaded
Open this post in threaded view
|

Re: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connecti

Freya
Same issue over here, anyone ideas how this was solved?


YJO wrote
Hi,

I'am accessing a webservice throug a proxy (that requeries authentication) over SSL and I keep getting this message : javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

This is what I do ?

          System.setProperty("javax.net.ssl.keyStore", keystoreUri);
        System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
        System.setProperty("javax.net.ssl.keyStoreType", "JKS");

        System.setProperty( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol" );
       
        System.setProperty("javax.net.ssl.trustStore", truststoreUri);
        System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
       
        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", "<myhost>");
        System.setProperty("http.proxyPort", "80");
        System.setProperty("http.proxyUser", "<myuser>");
        System.setProperty("http.proxyPassword", "<mypasswd>");

        System.setProperty("https.proxySet", "true");
        System.setProperty("https.proxyHost", "<my-host>");
        System.setProperty("https.proxyPort", "443");
        System.setProperty("https.proxyUser", "<myuser>");
        System.setProperty("https.proxyPassword", "<mypasswd>");
        System.setProperty("java.net.debug", "all");


Acessing the url of the webservice via the browser works fine also setting up a communication like here (see below) works fine. Yet the axis API doesn't offer me this to do(or am I wrong).

        try {
        javax.net.ssl.HttpsURLConnection connection = (javax.net.ssl.HttpsURLConnection)new URL("https://gmail.com").openConnection();
        String encoded = new String(org.apache.commons.codec.binary.Base64.encodeBase64(new String("<myuser>:<mypasswd>").getBytes()));
        connection.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
       
        connection.setHostnameVerifier(new HostnameVerifier(){
        public boolean verify(String urlHostName, SSLSession session) {
        return true;
        }
        });

        connection.connect();
        boolean b = connection.usingProxy();
        BufferedInputStream i = new BufferedInputStream(connection.getInputStream());
        StringBuffer sb = new StringBuffer();
            int c = 0;
            while ((c = i.read()) != -1) {
                sb.append((char) c);
            }
                       
        System.out.println("end");
        } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
        } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
    }