[英]How to make a request with HttpComponents (Java apache lib) changing Server Name Indication in TLS Handshake
I have to make a request to a backend with TLS certificate and private key and in my troubleshooting I got error when using the same hostname in the Server Name Indication.我必须使用 TLS 证书和私钥向后端发出请求,在我的故障排除中,我在服务器名称指示中使用相同的主机名时出错。 See:看:
I got ERROR:我收到错误:
openssl s_client -connect endpoint.com:443 -servername endpoint.com openssl s_client -connect endpoint.com:443 -servername endpoint.com
I got SUCCESS:我成功了:
openssl s_client -connect endpoint.com:443 -servername another_endpoint_name.com
But I can't find a way to change the server name indication in the TLS Handshake
in the Apache Lib.
但是我找不到在Apache Lib.
的TLS Handshake
中更改服务器名称指示的方法Apache Lib.
Is it even possible?甚至有可能吗?
Related question: How to set SNI (Server Name Indication) in TLS Handshake using Apache HttpComponents Java相关问题: 如何使用 Apache HttpComponents Java 在 TLS Handshake 中设置 SNI(服务器名称指示)
One can create a custom request route by using HttpHost
with a resolved InetAddress
.可以通过使用HttpHost
和解析的InetAddress
创建自定义请求路由。
Try out this code and let me know if that does the trick.试试这个代码,让我知道这是否有用。
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());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.