Remote host closed connection during handshake - javax.net.ssl.SSLHandshakeException

Hello All,

Here is my problem.

When I am trying to consume REST API, I am getting below error

Remote host closed connection during handshake. The detailed stack trace attached at the end.

However, when do test connection in service studio, I am able to hit the REST API and I get the json response back. Issue is only coming when I use the REST API in server action.

Why I am able to successfully consume RST API during test connection in outsystems but getting error on run time?

Stack trace:

[1] javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
   at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:994)
   at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
   at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
   at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
   at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
   at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.upgrade(DefaultHttpClientConnectionOperator.java:185)
   at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.upgrade(PoolingHttpClientConnectionManager.java:369)
   at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:415)
   at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
   at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
   at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
   at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
   at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
   at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
   at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
   at osmobiledashboard.actions.ActGetPriorityAlerts.executeGetPriorityAlerts(Unknown Source)
   at osmobiledashboard.screenservices.MobileDashboard_MainFlow_SCM_Controller.lambda$0(Unknown Source)
   at outsystems.restservice.controllers.ScreenServicesApiController$EndpointImplementationDelegate_Lambda.execute(Unknown Source)
   at outsystems.restservice.controllers.ScreenServicesApiController.endpoint(Unknown Source)
   at osmobiledashboard.screenservices.MobileDashboard_MainFlow_SCM_Controller.ActGetPriorityAlerts(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
   at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
   at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
   at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
   at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
   at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
   at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
   at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
   at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
   at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
   at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
   at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
   at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
   at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)
   at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
   at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
   at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
   at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
   at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
   at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at outsystems.hubedition.webwidgets.BaseRequestStartupFilter.doFilter(Unknown Source)
   at osmobiledashboard.RequestStartupFilter.doFilter(Unknown Source)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at outsystems.hubedition.webwidgets.filters.HttpContextFilter.doFilter(Unknown Source)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at outsystems.hubedition.webwidgets.filters.CacheControlFilter.doFilter(Unknown Source)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3436)
   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
   at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
   at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
   at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
   at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
   at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
   at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
   at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
   at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)

[2] java.io.EOFException: SSL peer shut down incorrectly
   at sun.security.ssl.InputRecord.read(InputRecord.java:505)
   at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975)
   at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
   at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
   at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
   at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
   at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.upgrade(DefaultHttpClientConnectionOperator.java:185)
   at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.upgrade(PoolingHttpClientConnectionManager.java:369)
   at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:415)
   at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
   at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
   at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
   at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
   at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
   at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
   at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
   at osmobiledashboard.actions.ActGetPriorityAlerts.executeGetPriorityAlerts(Unknown Source)
   at osmobiledashboard.screenservices.MobileDashboard_MainFlow_SCM_Controller.lambda$0(Unknown Source)
   at outsystems.restservice.controllers.ScreenServicesApiController$EndpointImplementationDelegate_Lambda.execute(Unknown Source)
   at outsystems.restservice.controllers.ScreenServicesApiController.endpoint(Unknown Source)
   at osmobiledashboard.screenservices.MobileDashboard_MainFlow_SCM_Controller.ActGetPriorityAlerts(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
   at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
   at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
   at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
   at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
   at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
   at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
   at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
   at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
   at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
   at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
   at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
   at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
   at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540)
   at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
   at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
   at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
   at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
   at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
   at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at outsystems.hubedition.webwidgets.BaseRequestStartupFilter.doFilter(Unknown Source)
   at osmobiledashboard.RequestStartupFilter.doFilter(Unknown Source)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at outsystems.hubedition.webwidgets.filters.HttpContextFilter.doFilter(Unknown Source)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at outsystems.hubedition.webwidgets.filters.CacheControlFilter.doFilter(Unknown Source)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3436)
   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
   at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
   at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
   at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
   at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
   at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
   at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
   at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
   at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)

Hi Arunkumar Balu,

Your application/Server Action is running on the Platform Server, whereas your testing takes place in Service Studio. Are those two machines (server running the OutSystems Platform Server and developer machine running Service Studio) configured the same way? apparently the SSL/HTTPS settings on the platform server seem to be the cause of the error (does the platform server have a valid SSL certificate, for instance?)

Platform server and service studio running in the same machine. This is a test machine where I am doing development and testing on the same server.

This is really confusing when it works at design time but not running when run time.

Agree with Jorge, you're probably going to find an SSL certificate issue at play.

At design time, it is your copy of Service Studio on your desktop doing the SSL connection to the REST service, at run time it is the Java application container on the server doing the connection, they may have very different lists of trusted certificates.

J.Ja

Justin James wrote:

Agree with Jorge, you're probably going to find an SSL certificate issue at play.

At design time, it is your copy of Service Studio on your desktop doing the SSL connection to the REST service, at run time it is the Java application container on the server doing the connection, they may have very different lists of trusted certificates.

J.Ja

I don't think so. During design time, I am connected to the environment and test connection call is going from the environment where I have connected.

Earlier, even the test connection was failing. I have imported the SSL certificate into the server environment, then the test connection (design time) has started working. I thought everything would be fine then, but surprised when it is not working during run time. (Please dev and front-end is the same server)

I think that proves that design time and run time is in the same environment. However, one work others don't


I have used below instructions to install the certificate into the environment. 


https://success.outsystems.com/Support/Enterprise_Customers/Installation/Install_a_trusted_root_CA__or_self-signed_certificate

Thereafter, the test connection started working. but run time connection is not.

Hi Arunkumar.

Did you follow the instructions to install the certificate on a Windows machine or a Linux machine?

The error you provided is a Java error, which means your platform server is running on a Linux machine. Your development environment (Service Studio) is a Windows desktop application. So they cannot be the same machine.

I suspect that you have installed the certificate on your development environment (the Windows machine running Service Studio). If that's the case, then you must also install the certificate on the Linux machine running your platform server.

I have followed the instruction given for the Linux machine. I have installed the certificate on the linux server where the platform server installed. But still the error.

Fortunately, I have another windows environment. I follow the instruction given on the same page. I have installed the certificate there. It is working if I connect to windows environment. So that I am able to continue. 

But still, it is an issue with Linux stack.

Your error is a closed connection by remote host, so it would be good if you could obtain logs from the remote host to see if there's any reason why it's rejecting the linux requests.

This could be related to the TLS version being supported by the remote host. If the remote host supports only TLS 1.2, and weblogic is trying to connect using TLS 1.0 or 1.1, then you won't be able to connect, even though you have correctly installed the certificate.

There are online tools that show which TLS versions your server is accepting, for example: https://www.ssllabs.com/ssltest/. On your weblogic client, you can add the option -javax.net.debug=ssl to the JVM initialization script, and this will log information about the SSL handshake, including the TLS version being used. You can then compare the versions and see if there's a mismatch.