You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "sushl (JIRA)" <ji...@apache.org> on 2013/10/07 15:45:42 UTC

[jira] [Updated] (AXIS2-5610) SSL Connection fail through Proxy server(mod_proxy) using java(Axis2)

     [ https://issues.apache.org/jira/browse/AXIS2-5610?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

sushl updated AXIS2-5610:
-------------------------

    Description: 
I am using Java(Axis2) to connect .net web service. created stub class from WSDL2Java Converter. 
Proxy Server : Apache mod_proxy

Try to access code from C# and Java
below all cases are working with the C#, but getting error with the Java(Axis2)
(SSL = true, Proxy = false  : Success)
(SSl = false, Proxy = true : Success)
(SSL = true, Proxy = true : Fail (class javax.net.ssl.SSLException))

code:
ServiceStub objStub = new ServiceStub(sWebServiceURL);

//Setting Chunk http data to false and Cookie ID
			objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
			objStub._getServiceClient().getOptions().setProperty("customCookieID",DEF_COOKIEID);
			objStub._getServiceClient().getOptions().setManageSession(true);

// In case of Proxy setting (HttpTransportProperties.ProxyProperties)
objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.PROXY, objProxyProperties);

objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, objAuthenticator);

// to work without certifcate 
objProtocol = new Protocol("https", new MySocketFactory(), 443);
					objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER, objProtocol);

// inside MySocketFactory I am using follwoing function
public Socket createSocket(final String host,
							   final int port,
							   final InetAddress localAddress,
							   final int localPort,
							   final HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException 
	{
		if (params == null) 
		{
			throw new IllegalArgumentException("Parameters may not be null");
		}
		int timeout = params.getConnectionTimeout();
		SocketFactory socketfactory = getSSLContext().getSocketFactory();
		if (timeout == 0) 
		{
			return socketfactory.createSocket(host, port, localAddress, localPort);
		}
		else 
		{
			Socket socket = socketfactory.createSocket();
			SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
			SocketAddress remoteaddr = new InetSocketAddress(host, port);
			socket.bind(localaddr);
			socket.connect(remoteaddr, timeout);
			return socket;
		}
	}

private static SSLContext createEasySSLContext() 
	{
		try 
		{
			SSLContext context = SSLContext.getInstance("SSL");
			context.init(null, new TrustManager[] {new NaiveTrustManager()}, null);
			return context;
		}
		catch (Exception e) 
		{
			LOG.error(e.getMessage(), e);
			throw new HttpClientError(e.toString());
		}
	}


Exception Message: Unrecognized SSL message, plaintext connection? Stack Trace: org.apache.axis2.AxisFault: Unrecognized SSL message, plaintext connection?

Apache access.log
10.128.43.60 - - [24/Sep/2013:13:49:02 +0900] "\x16\x03\x01" 501 215






 

  was:
I am using Java(Axis2) to connect .net web service. created stub class from WSDL2Java Converter. 
Proxy Server : Apache mod_proxy

Try to access code from C# and Java
below all cases are working with the C#, but getting error with the Java(Axis2)
(SSL = true, Proxy = false  : Success)
(SSl = false, Proxy = true : Success)
(SSL = true, Proxy = true : Fail (class javax.net.ssl.SSLException))

code:
ServiceStub objStub = new ServiceStub(sWebServiceURL);

//Setting Chunk http data to false and Cookie ID
			objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
			objStub._getServiceClient().getOptions().setProperty("customCookieID",DEF_COOKIEID);
			objStub._getServiceClient().getOptions().setManageSession(true);

// In case of Proxy setting (HttpTransportProperties.ProxyProperties)
objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.PROXY, objProxyProperties);

objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, objAuthenticator);

// to work without certifcate 
objProtocol = new Protocol("https", new NaiveSocketFactory(), 443);
					objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER, objProtocol);

// inside NaiveSocketFactory I am using follwoing function
public Socket createSocket(final String host,
							   final int port,
							   final InetAddress localAddress,
							   final int localPort,
							   final HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException 
	{
		if (params == null) 
		{
			throw new IllegalArgumentException("Parameters may not be null");
		}
		int timeout = params.getConnectionTimeout();
		SocketFactory socketfactory = getSSLContext().getSocketFactory();
		if (timeout == 0) 
		{
			return socketfactory.createSocket(host, port, localAddress, localPort);
		}
		else 
		{
			Socket socket = socketfactory.createSocket();
			SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
			SocketAddress remoteaddr = new InetSocketAddress(host, port);
			socket.bind(localaddr);
			socket.connect(remoteaddr, timeout);
			return socket;
		}
	}

private static SSLContext createEasySSLContext() 
	{
		try 
		{
			SSLContext context = SSLContext.getInstance("SSL");
			context.init(null, new TrustManager[] {new NaiveTrustManager()}, null);
			return context;
		}
		catch (Exception e) 
		{
			LOG.error(e.getMessage(), e);
			throw new HttpClientError(e.toString());
		}
	}


Exception Message: Unrecognized SSL message, plaintext connection? Stack Trace: org.apache.axis2.AxisFault: Unrecognized SSL message, plaintext connection?

Apache access.log
10.128.43.60 - - [24/Sep/2013:13:49:02 +0900] "\x16\x03\x01" 501 215






 


> SSL Connection fail through Proxy server(mod_proxy) using java(Axis2)
> ---------------------------------------------------------------------
>
>                 Key: AXIS2-5610
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5610
>             Project: Axis2
>          Issue Type: Bug
>          Components: client-api, wsdl
>    Affects Versions: 1.6.1
>         Environment: OS:Windows 7
> IDE: Eclipse
> WebService: C#
> Client Application:  java
>            Reporter: sushl
>              Labels: security
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I am using Java(Axis2) to connect .net web service. created stub class from WSDL2Java Converter. 
> Proxy Server : Apache mod_proxy
> Try to access code from C# and Java
> below all cases are working with the C#, but getting error with the Java(Axis2)
> (SSL = true, Proxy = false  : Success)
> (SSl = false, Proxy = true : Success)
> (SSL = true, Proxy = true : Fail (class javax.net.ssl.SSLException))
> code:
> ServiceStub objStub = new ServiceStub(sWebServiceURL);
> //Setting Chunk http data to false and Cookie ID
> 			objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
> 			objStub._getServiceClient().getOptions().setProperty("customCookieID",DEF_COOKIEID);
> 			objStub._getServiceClient().getOptions().setManageSession(true);
> // In case of Proxy setting (HttpTransportProperties.ProxyProperties)
> objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.PROXY, objProxyProperties);
> objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, objAuthenticator);
> // to work without certifcate 
> objProtocol = new Protocol("https", new MySocketFactory(), 443);
> 					objStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER, objProtocol);
> // inside MySocketFactory I am using follwoing function
> public Socket createSocket(final String host,
> 							   final int port,
> 							   final InetAddress localAddress,
> 							   final int localPort,
> 							   final HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException 
> 	{
> 		if (params == null) 
> 		{
> 			throw new IllegalArgumentException("Parameters may not be null");
> 		}
> 		int timeout = params.getConnectionTimeout();
> 		SocketFactory socketfactory = getSSLContext().getSocketFactory();
> 		if (timeout == 0) 
> 		{
> 			return socketfactory.createSocket(host, port, localAddress, localPort);
> 		}
> 		else 
> 		{
> 			Socket socket = socketfactory.createSocket();
> 			SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
> 			SocketAddress remoteaddr = new InetSocketAddress(host, port);
> 			socket.bind(localaddr);
> 			socket.connect(remoteaddr, timeout);
> 			return socket;
> 		}
> 	}
> private static SSLContext createEasySSLContext() 
> 	{
> 		try 
> 		{
> 			SSLContext context = SSLContext.getInstance("SSL");
> 			context.init(null, new TrustManager[] {new NaiveTrustManager()}, null);
> 			return context;
> 		}
> 		catch (Exception e) 
> 		{
> 			LOG.error(e.getMessage(), e);
> 			throw new HttpClientError(e.toString());
> 		}
> 	}
> Exception Message: Unrecognized SSL message, plaintext connection? Stack Trace: org.apache.axis2.AxisFault: Unrecognized SSL message, plaintext connection?
> Apache access.log
> 10.128.43.60 - - [24/Sep/2013:13:49:02 +0900] "\x16\x03\x01" 501 215
>  



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org