Я наконец нашел способ сделать это, посмотрев на исходный код Citrus, вот что я придумал, чтобы заставить его работать, просто поместив его здесь на случай, если это поможет кому-то еще:
@Bean
public HttpComponentsClientHttpRequestFactory mySSLBasicAuthRequestFactory() throws Exception {
AuthScope authScope = new AuthScope(myServer, myPort, "", "basic");
HttpComponentsClientHttpRequestFactory myHttpComponentsClientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory() {
@Override
protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
// we have to use preemptive authentication
// therefore add some basic auth cache to the local context
AuthCache authCache = new BasicAuthCache();
BasicScheme basicAuth = new BasicScheme();
// authCache.put(new HttpHost(authScope.getHost(), authScope.getPort(), "http"), basicAuth);
authCache.put(new HttpHost(authScope.getHost(), authScope.getPort(), "https"), basicAuth);
BasicHttpContext localcontext = new BasicHttpContext();
localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
return localcontext;
}
};
UsernamePasswordCredentials myCredentials = new UsernamePasswordCredentials(myUser, myPassword);
CredentialsProvider provider = new BasicCredentialsProvider();
provider.setCredentials(AuthScope.ANY, myCredentials);
CloseableHttpClient myHttpClient = HttpClients.custom()
.setSSLHostnameVerifier(new NoopHostnameVerifier())
.setDefaultCredentialsProvider(provider)
.setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, (x509Certificates, s) -> true)
.build())
.build();
myHttpComponentsClientHttpRequestFactory.setHttpClient(myHttpClient);
return myHttpComponentsClientHttpRequestFactory;
}