JavaCallout invoke service with Self signed cert

Not applicable

We have a requirement to invoke one service endpoint from Java Callout which has the self signed host. Since NTLM is enabled on the service endpoint, we are trying to implement the NTLM Authentication in JavaCallout.

Does JavaCallout refers to the Apigee trust-store created for a particular environment ? If no what are the ways to invoke the endpoint with self signed cert from Java Callout ?

Currently getting following error from JavaCallout using HttpClient:

java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) 
at java.net.SocketInputStream.read(SocketInputStream.java:141) 
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) 
at sun.security.ssl.InputRecord.read(InputRecord.java:503) 
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) 
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) 
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) 
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) 
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396) 
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355) 
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) 
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) 
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) 
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) 
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) 
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) 
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) 
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) 
at com.test.NTLMAlternate.execute(NTLMAlternate.java:104) 
at com.apigee.steps.javacallout.JavaCalloutStepDefinition$ClassLoadWrappedExecution.execute(JavaCalloutStepDefinition.java:164) 
at com.apigee.steps.javacallout.JavaCalloutStepDefinition$SecurityWrappedExecution$1.run(JavaCalloutStepDefinition.java:229) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.apigee.steps.javacallout.JavaCalloutStepDefinition$SecurityWrappedExecution.execute(JavaCalloutStepDefinition.java:227) 
at com.apigee.steps.javacallout.JavaCalloutStepDefinition$CallOutWrapper.execute(JavaCalloutStepDefinition.java:99) 
at com.apigee.messaging.runtime.steps.StepExecution.execute(StepExecution.java:143) 
at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:77) 
at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:46) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
at java.lang.Thread.run(Thread.java:748)
<br>
Solved Solved
0 1 337
1 ACCEPTED SOLUTION

You can include your keystore, certs, keys, etc as part of the jar and later load them as:

this.getClass().getClassLoader().getResourseAsStream(“<path to file within jar>”);

I can’t recall if path to file within jar is absolute or relative, nevertheless you can try both.

Hope it helps, thanks

View solution in original post

1 REPLY 1

You can include your keystore, certs, keys, etc as part of the jar and later load them as:

this.getClass().getClassLoader().getResourseAsStream(“<path to file within jar>”);

I can’t recall if path to file within jar is absolute or relative, nevertheless you can try both.

Hope it helps, thanks