1

I'm consuming data from a REST endpoint with in the middle of the route a proxy. I'm having CNTLM running locally (localhost:3128 ): it will authenticate for me on the corporate proxy, so I don't need to pass my credentials.

I have been unable to get my rest call to work, despite numerous attempts. For e.g., getting:

  • SSLException: Unrecognized SSL message
  • Connection handshake abruptly terminated
  • Connection reset
  • you name it, have got it

Below the simplest version of the many attempts made. Apparently (from internet reading), that should work, but it doesn't.

How should Camel be configured, in particular camel-http ?

Notes: The REST API I'm calling is using HTTPS but doesn't require a certificate. The code works on my local machine when no proxy is involved. It fails on the intranet where there is a proxy

@Component
public class MyRoute extends RouteBuilder

    public void configure() throws Exception {

        //Tried different way to set the proxy, including inline with toD(...)
        System.setProperty("https.proxyHost", "localhost");
        System.setProperty("https.proxyPort", "3128");
        getCamelContext().getGlobalOptions().put("http.proxyHost", "localhost");
        getCamelContext().getGlobalOptions().put("https.proxyPort", "3128");
        getContext().getGlobalOptions().put("https.proxyHost", "localhost");
        getContext().getGlobalOptions().put("https.proxyPort", "3128");

        from("timer:credentials?repeatCount=1")
        .setHeader(Exchange.HTTP_METHOD, constant("POST"))
        .setBody(simple(jsonAuth))
        .to(baseUrlApi +"/v1/auth/tokens/?bridgeEndpoint=true")
        .unmarshal().json(JsonLibrary.Jackson, AuthResponseDto.class)
        .setHeader("Authorization", simple("Bearer ${body.data.accessToken.token}"))
        // etc..

    }
}
Hey StackExchange
  • 2,057
  • 3
  • 19
  • 35
  • Check these 1. The TLS Certificate of your service - Is this issued by a well known CA or by yor internal CA 2. Does the corporate proxy perform TLS inspection (Swapping in a new certificate instead of the one presented by target service) – ShellDragon Nov 17 '21 at 17:01
  • @ShellDragon: The CA is a well known CA. In the chain is below my company, and below the certificate of the company I'm trying to reach. – Hey StackExchange Nov 17 '21 at 18:02

0 Answers0