You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by droytenberg <dr...@yahoo.com> on 2013/07/26 21:06:36 UTC

Configuring a proxy server to connect over https

I've dug around on the web and haven't found an explanation of this precise
scenario.

We have created a web service client using CXF.  We are using wsdl2java to
generate our domain classes and Spring to define our web service client.  We
have configured our certificates in the JVM and are connecting successfully
over https to our target web service.

Now we are trying to introduce a proxy server between the client application
and the remote web service.  If we connect locally using http to port 8080
the request is correctly passed through the proxy server and we get our
result just as when we connect directly.

However, when we connect to our proxy server over https via port 9443, CXF
waits until its default timeout has elapsed, then reports that there is an
empty response from the proxy server, and then retries the direct 
connection, successfully completing the call.

Here is the error we are getting:

javax.xml.ws.soap.SOAPFaultException: Unexpected end of file from server
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:155)
	at com.sun.proxy.$Proxy67.enrollNewMember(Unknown Source)
	at
com.optimal.prepaid.gateway.lcp.service.LcpGateway.enrollNewMember(LcpGateway.java:671)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
	at com.sun.proxy.$Proxy68.enrollNewMember(Unknown Source)
	at
com.optimal.prepaid.gateway.lcp.EnrollNewMemberTest.test(EnrollNewMemberTest.java:128)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at
org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.ctc.wstx.exc.WstxIOException: Unexpected end of file from
server
	at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:261)
	at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:103)
	at
org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
	at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
	... 42 more
Caused by: java.net.SocketException: Unexpected end of file from server
	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:782)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:641)
	at
sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:1618)
	at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:164)
	at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031)
	at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
	at
org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.setupWrappedStream(URLConnectionHTTPConduit.java:168)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1282)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1233)
	at
org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionHTTPConduit.java:195)
	at
org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47)
	at
org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
	at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:100)
	at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:225)
	at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:259)
	... 51 more



Here is the configuration for the proxy server.  I've disabled chunking
because this was one
suggestion of how to resolve proxy connection issues, but it doesn't seem to
make any difference:


....
    HTTPConduit conduit = (HTTPConduit)cxfClient.getConduit(); 
    
    HTTPClientPolicy policy =  conduit.getClient();
       // Set the proxy server ...
    policy.setProxyServer("ip addresss for proxy server");
    // ... and the proxy server port
    policy.setProxyServerPort(9443);
    policy.setProxyServerType(ProxyServerType.HTTP);
    // Disable chunking.  
    policy.setAllowChunking(false);
......

Does this mean there is something wrong with our infrastructure or is it
possible that there is more configuration that we have to do
programmatically?

We're stuck.  So any suggestions will be gratefully received.

David Roytenberg



--
View this message in context: http://cxf.547215.n5.nabble.com/Configuring-a-proxy-server-to-connect-over-https-tp5731511.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Configuring a proxy server to connect over https

Posted by droytenberg <dr...@yahoo.com>.
I can add a bit more information:  This request works fine if we send it to
the proxy server over the http port instead of over the SSL port.  So I
think this must be a problem with our infrastructure and not with what we
are doing in the app.  Anybody disagree?

David



droytenberg wrote
> I've dug around on the web and haven't found an explanation of this
> precise scenario.
> 
> ...
> 
> Here is the configuration for the proxy server.  I've disabled chunking
> because this was one
> suggestion of how to resolve proxy connection issues, but it doesn't seem
> to make any difference:
> 
> 
> ....
>     HTTPConduit conduit = (HTTPConduit)cxfClient.getConduit(); 
>     
>     HTTPClientPolicy policy =  conduit.getClient();
>        // Set the proxy server ...
>     policy.setProxyServer("ip addresss for proxy server");
>     // ... and the proxy server port
>     policy.setProxyServerPort(9443);
>     policy.setProxyServerType(ProxyServerType.HTTP);
>     // Disable chunking.  
>     policy.setAllowChunking(false);
> ......
> 
> Does this mean there is something wrong with our infrastructure or is it
> possible that there is more configuration that we have to do
> programmatically?
> 
> We're stuck.  So any suggestions will be gratefully received.
> 
> David Roytenberg





--
View this message in context: http://cxf.547215.n5.nabble.com/Configuring-a-proxy-server-to-connect-over-https-tp5731511p5731670.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Configuring a proxy server to connect over https

Posted by Jason Pell <ja...@pellcorp.com>.
ssl proxy certainly works with cxf. In our project we connect to a cntlm
based proxy over ssl and that works fine.

Can you stick tcpmon in the middle. Even with ssl you should be able to
monitor the headers and negotiations.
On 27/07/2013 5:07 AM, "droytenberg" <dr...@yahoo.com> wrote:

> I've dug around on the web and haven't found an explanation of this precise
> scenario.
>
> We have created a web service client using CXF.  We are using wsdl2java to
> generate our domain classes and Spring to define our web service client.
>  We
> have configured our certificates in the JVM and are connecting successfully
> over https to our target web service.
>
> Now we are trying to introduce a proxy server between the client
> application
> and the remote web service.  If we connect locally using http to port 8080
> the request is correctly passed through the proxy server and we get our
> result just as when we connect directly.
>
> However, when we connect to our proxy server over https via port 9443, CXF
> waits until its default timeout has elapsed, then reports that there is an
> empty response from the proxy server, and then retries the direct
> connection, successfully completing the call.
>
> Here is the error we are getting:
>
> javax.xml.ws.soap.SOAPFaultException: Unexpected end of file from server
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:155)
>         at com.sun.proxy.$Proxy67.enrollNewMember(Unknown Source)
>         at
>
> com.optimal.prepaid.gateway.lcp.service.LcpGateway.enrollNewMember(LcpGateway.java:671)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
>
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
>         at
>
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
>         at com.sun.proxy.$Proxy68.enrollNewMember(Unknown Source)
>         at
>
> com.optimal.prepaid.gateway.lcp.EnrollNewMemberTest.test(EnrollNewMemberTest.java:128)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
>
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
>         at
>
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>         at
>
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
>         at
>
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>         at
>
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>         at
>
> org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
>         at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
>         at
>
> org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
>         at
>
> org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
>         at
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
>         at
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
>         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>         at
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>         at
>
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>         at
>
> org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
>         at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
>         at
>
> org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>         at
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
>         at
>
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>         at
>
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>         at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>         at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>         at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>         at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: com.ctc.wstx.exc.WstxIOException: Unexpected end of file from
> server
>         at
> com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:261)
>         at
>
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:103)
>         at
>
> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
>         at
>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>         at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
>         at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
>         ... 42 more
> Caused by: java.net.SocketException: Unexpected end of file from server
>         at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:782)
>         at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:641)
>         at
>
> sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:1618)
>         at
>
> sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:164)
>         at
>
> sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031)
>         at
>
> sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
>         at
>
> org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.setupWrappedStream(URLConnectionHTTPConduit.java:168)
>         at
>
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1282)
>         at
>
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1233)
>         at
>
> org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionHTTPConduit.java:195)
>         at
>
> org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47)
>         at
>
> org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
>         at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:100)
>         at
> com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:225)
>         at
> com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:259)
>         ... 51 more
>
>
>
> Here is the configuration for the proxy server.  I've disabled chunking
> because this was one
> suggestion of how to resolve proxy connection issues, but it doesn't seem
> to
> make any difference:
>
>
> ....
>     HTTPConduit conduit = (HTTPConduit)cxfClient.getConduit();
>
>     HTTPClientPolicy policy =  conduit.getClient();
>        // Set the proxy server ...
>     policy.setProxyServer("ip addresss for proxy server");
>     // ... and the proxy server port
>     policy.setProxyServerPort(9443);
>     policy.setProxyServerType(ProxyServerType.HTTP);
>     // Disable chunking.
>     policy.setAllowChunking(false);
> ......
>
> Does this mean there is something wrong with our infrastructure or is it
> possible that there is more configuration that we have to do
> programmatically?
>
> We're stuck.  So any suggestions will be gratefully received.
>
> David Roytenberg
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Configuring-a-proxy-server-to-connect-over-https-tp5731511.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>