Apache HTTPClient 和 Websphere Application Server 配置

Apache HTTPClient and Websphere Application Server Configuration

我将 WebSphere Application Server 8.5 和 Apache HTTPClient 4.5.2 用于 REST 消费者项目。基本上,我们使用 HTTPClient 发出 HTTP 请求(更像是 HTTPS)以使用 REST Web 服务。我们有 2 个不同的项目:一个在 .ear 文件中,另一个在 OSGI 包中(它们是独立的)

但问题是一样的:我想将来自 WAS 的配置(SSL 配置、证书)用于我的 httpclient 连接。

我该怎么做?可能吗?

谢谢。

默认情况下,Apache 的 HttpClient 创建自己的 SSLContext 实例,导致它不获取 WAS 的实例。您可以通过调用 useSystemProperties() 方法使 HttpClient 不创建自己的实例。例如,调用 HttpClient 看起来像这样:

HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties()