Hi, I am seeing an SSLException if I use a proxy: ( The IP Address and the 
Domain name below is altered by me).

javax.net.ssl.SSLException: hostname in certificate didn't match: <1.2.3.4> != 
<secure.bank.com> . 
org.apache.http.conn.ssl.AbstractVerifier.verify 236
org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify 54
org.apache.http.conn.ssl.AbstractVerifier.verify 152
org.apache.http.conn.ssl.AbstractVerifier.verify 133
org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname 287
org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket 277
org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket 255
org.apache.http.impl.conn.HttpClientConnectionOperator.connect 118
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect 314
org.apache.http.impl.execchain.MainClientExec.establishRoute 371
…

If I do not use a proxy everything works.

My code:

CachingHttpClientBuilder builder = (CachingHttpClientBuilder) 
CachingHttpClientBuilder.create().setCacheConfig(cacheConfig)
                                        
.setKeepAliveStrategy(myStrategy).setConnectionManager(cManager);
CloseableHttpClient hClient = builder.build();

HttpGet httpget = new HttpGet(“https://secure.bank.com";);
HttpHost proxy = new HttpHost( “1.2.3.4", 443, isHttps ? "https" : "http");
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
httpget.setConfig(config);
HttpCacheContext context = HttpCacheContext.create();
response = client.execute(httpget, context);
…

BTW in my environment, 1.2.3.4 is the calculated IP address for 
secure.bank.com. So I am really trying to use the proxy as a way to route the 
request to the next hop. Am I doing it wrong? 
Thanks
ning

Reply via email to