我必须向带有TLS证书和私钥的后端发出请求,在我的故障排除中,在服务器名称指示中使用相同的主机名时出现错误。看:
我收到错误:
OpenSSL s_client -connect endpoint.com:443 -servername endpoint.com
我成功了:
openssl s_client -connect endpoint.com:443 -servername another_endpoint_name.com
但是我找不到更改Apache Lib.
TLS Handshake
中服务器名称指示的方法 甚至可能吗?
相关问题:如何使用Apache HttpComponents Java在TLS握手中设置SNI(服务器名称指示(
可以使用具有解析InetAddress
的HttpHost
创建自定义请求路由。
试试这段代码,让我知道这是否可行。
CloseableHttpClient httpClient = HttpClients.createSystem();
HttpHost host = new HttpHost(InetAddress.getByName("endpoint.com"), "another_endpoint_name.com", -1, "https");
try (CloseableHttpResponse response = httpClient.execute(host, new HttpGet("https://another_endpoint_name.com/stuff"))) {
System.out.println(response.getStatusLine());
EntityUtils.consume(response.getEntity());
}