Urgent : SSLException: Unrecognized SSL message, plaintext connection

I try to ask a webservice to an url in https with certificate.

This is my code (confidential informations was replaced by "####" :

package essai;

import java.net.Authenticator;

import java.util.List;

import javax.activation.DataHandler;

import javax.activation.FileDataSource;

import javax.xml.namespace.QName;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

public class Essai {

public static void main(String[] args) {

try {

System.out.println("Debut");

Service monservice = new Service();

System.getProperties().put("http.proxySet" , "true");

System.getProperties().put("http.proxyHost","proxy");

System.getProperties().put("http.proxyPort", "8080"); //443

System.getProperties().put("proxyUser ", "####");

System.getProperties().put("proxyPassword", "####");

System.setProperty("javax.net.ssl.trustStore", "monalias");

System.setProperty("javax.net.ssl.trustStorePassword", "");

System.setProperty("javax.net.ssl.keyStore", "C:\\APPFT\\j2sdk1.4.2_08\\jre\\lib\\security\\cacerts");

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");

Call call;

call = (Call) monservice.createCall();

DataHandler dhSource = new DataHandler(new FileDataSource("C:\\kruidvatleuven.xml"));

call.setTargetEndpointAddress(new java.net.URL("https://www.######/####"));

call.setOperationName(new QName("CheckAdress"));

call.setReturnType(org.apache.axis.Constants.XSD_STRING);

//call.setUsername("####");

//call.setPassword("####");

call.addParameter("testParam",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

call.invoke(new Object[] { dhSource });

List rtnValues = call.getOutputValues();

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

System.out.println("Fin");

} catch (Exception e) {

e.printStackTrace();

}

}

}

I have execute this command line to load certificate :

keytool -import -alias monalias -file C:\\xxxx.cer -trustcacerts -storetype JKS -keystore C:/APPFT/j2sdk1.4.2_08/jre/lib/security/cacerts -storepass changeit

I have these logs :

Debut

AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

faultActor:

faultNode:

faultDetail:

{http://xml.apache.org/axis/}stackTrace:javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

at com.sun.net.ssl.internal.ssl.InputRecord.b(DashoA12275)

at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA12275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)

at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)

at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:131)

at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:370)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:88)

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:147)

at org.apache.axis.client.Call.invokeEngine(Call.java:2719)

at org.apache.axis.client.Call.invoke(Call.java:2702)

at org.apache.axis.client.Call.invoke(Call.java:2378)

at org.apache.axis.client.Call.invoke(Call.java:2301)

at org.apache.axis.client.Call.invoke(Call.java:1758)

at essai.Essai.main(Essai.java:64)

{http://xml.apache.org/axis/}hostname:FT-8E6B46FD4908

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:97)

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:147)

at org.apache.axis.client.Call.invokeEngine(Call.java:2719)

at org.apache.axis.client.Call.invoke(Call.java:2702)

at org.apache.axis.client.Call.invoke(Call.java:2378)

at org.apache.axis.client.Call.invoke(Call.java:2301)

at org.apache.axis.client.Call.invoke(Call.java:1758)

at essai.Essai.main(Essai.java:64)

Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

at com.sun.net.ssl.internal.ssl.InputRecord.b(DashoA12275)

at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA12275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)

at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)

at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:131)

at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:370)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:88)

... 10 more

Can you help me. Can I pass proxy ? Is my keystore config for certificate ok ?

[6024 byte] By [Xtaza] at [2007-9-25]
# 1

The exception text says it all.

You should be setting https.proxyHost/proxyPort, not http.*.

BTW you can get rid of http.proxySet, it does nothing, and

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

as well if you are running JDK >= 1.4.

Are you sure the target server is running HTTPS? Normally it would be running HTTP at port 80, and HTTPS at port 443 if you so configure it.

ejpa at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...
# 2

Firstly, thank you for you answer.

I have tested this on a pc with no proxy and it work fine.

I have changed http in https like that :

System.getProperties().put("https.proxySet" , "true");

System.getProperties().put("https.proxyHost","proxy");

System.getProperties().put("https.proxyPort", "8080");

System.getProperties().put("https.proxyUser ", "####");

System.getProperties().put("https.proxyPassword", "####");

But on port 443, the answer is : "Connection refused"

And on the port 8080 or 80, the answer is the same : "javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?"

Any idees ?

Xtaza at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...
# 3

The ideas are much the same as before.

(a) https.proxySet does nothing

(b) ports 80 and 8080 are generally plaintext ports, hence the plaintext connection? message

(c) The server is not listening at port 443 via SSL, hence the 'connection refused' exception.

You have to fix (c) at your server somehow.

ejpa at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...
# 4
Ok thank you very much for your help. (for information I doesn't have lead on server and I should ask for special access ;-)) )
Xtaza at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...
# 5
Hi I am using Axis client in a standalone java application. I am trying to accessing an https SOAP service through a proxy. I am still getting the same error after all suggestions provided here.
vasanthiKa at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...
# 6
If you're getting the message 'plaintext connection?' then you probably really do have a plaintext connection.
ejpa at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...