1

弹簧集成 4:

我想与 HTTPS 的 http outbound-gateway 进行通信。即使用安全协议。要求是我想使用 URL“https://”,但我们没有证书并且需要绕过它。

4

1 回答 1

1

我在一些旧项目中发现了这个配置:

<bean id="clientHttpRequestFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory"/>
<!--TODO waiting HttpClient SSL impl <bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"/>-->

而且我记得这种CommonsClientHttpRequestFactoryforcommons-http-client-3.0允许接受所有服务器证书。否则,您应该自定义HttpComponentsClientHttpRequestFactorycommons-http-client-4.x如下所示:

CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()

在此答案中查看更多信息:如何忽略 Apache HttpClient 4.0 中的 SSL 证书错误

在自定义之后,您只需将其注入clientHttpRequestFactory<int-http:outbound-gateway>.

于 2015-05-07T10:19:09.877 回答