You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Benjamin Janes <be...@gmail.com> on 2020/10/07 10:17:34 UTC

Updating the host name header Apache CXF 3.3.1

Hi,

I have a simple Apache CXF Client, using

  List<Object> providers = new ArrayList<Object>();
  providers.add(new JSONProvider());
  WebClient client = WebClient.create(url, providers);
  HTTPConduit httpConduit = WebClient.getConfig(client).getHttpConduit();
  loadTrustStore(httpConduit);

  client.type(new MediaType("application", "json", "UTF-8"));
  client.accept(new MediaType("application", "json", "UTF-8"));
  client.replaceHeader("Host", "plus.dnb.com");
  return client;

Here I can set headers as required and it works, the host header becomes
the dns of the end server "fred.bloggs.com"

However when I neeed to use a proxy and I call the proxy via an IP address
in the request y requests fail as the Host header is not the actual host,
so the Host header becomes the IP of the proxy: 12.234.53.23

As such there is an issue as the fred.bloggs.com server causes a Gateway
Timeout. If using curl I set the Host header to the correct value whilst
using the proxy it works.

However I noted that due the the use of the inbuild Java solution I was
unable to alter the host header from my simple client.

So I built an Async client, however now I get errors saying the SSL name of
the certicate so (fred.bloggs.com) does not match the host name which is
the I.P.. This was disabled in the simple client using:

TLSClientParameters tlsParams = new TLSClientParameters();
    tlsParams.setSecureSocketProtocol(sslProtocol);
    tlsParams.setTrustManagers(tmf.getTrustManagers());tlsParams.setDisableCNCheck(true);

I am unable to find something similar in Async, further i fail to see
where I set a HostNameVerifier class to override this information for
an Async solution

Using the following clietn: CloseableHttpAsyncClient httpclient;

Any ideas please

Many thanks

/Benjamin Janes