Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用Apache HTTP组件为每个路由配置SSLSocket工厂_Java_Ssl_Client Server_Apache Httpclient 4.x_Apache Httpcomponents - Fatal编程技术网

Java 如何使用Apache HTTP组件为每个路由配置SSLSocket工厂

Java 如何使用Apache HTTP组件为每个路由配置SSLSocket工厂,java,ssl,client-server,apache-httpclient-4.x,apache-httpcomponents,Java,Ssl,Client Server,Apache Httpclient 4.x,Apache Httpcomponents,有没有办法为Apache HTTP客户端中的每个路由设置单独的SSL上下文工厂。从文档中我只能看到,我们可以根据方案而不是路由配置SSLContextFactory Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", plainsf) .register("https

有没有办法为Apache HTTP客户端中的每个路由设置单独的SSL上下文工厂。从文档中我只能看到,我们可以根据方案而不是路由配置SSLContextFactory

Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", plainsf)
            .register("https", sslsf)
            .build();

    HttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(r);
    HttpClients.custom()
            .setConnectionManager(cm)
            .build();
注册表r=RegistryBuilder.create() .register(“http”,plainsf) .注册(“https”,sslsf) .build(); HttpClientConnectionManager cm=新池TpClientConnectionManager(r); HttpClients.custom() .setConnectionManager(cm) .build(); 我的所有目标端点都受HTTPS保护,并强制执行客户端证书身份验证。对于这些端点中的每一个,我必须选择一个特定的客户端证书并将其呈现给端点服务器。目前我看到的唯一方法是为每个目标端点路由创建一个单独的HTTPClient实例&使用SSLContext工厂实例进行配置

我在这里寻找任何改进这种设计的指针


谢谢。

我已经在Apache HTTP客户端论坛上发布了这个问题,并获得了如何处理这个问题的解决方案

可以使用“http.socket factory registry”上下文属性对其进行设置 结束,但请注意此功能被视为未记录

还请注意,可以构建自定义ConnectionSocketFactory 它在创建SSL套接字时使用自定义上下文属性。 这将是解决这个问题的推荐方法


为什么?你想解决什么问题?