弹簧集成 4:
我想与 HTTPS 的 http outbound-gateway 进行通信。即使用安全协议。要求是我想使用 URL“https://”,但我们没有证书并且需要绕过它。
弹簧集成 4:
我想与 HTTPS 的 http outbound-gateway 进行通信。即使用安全协议。要求是我想使用 URL“https://”,但我们没有证书并且需要绕过它。
我在一些旧项目中发现了这个配置:
<bean id="clientHttpRequestFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory"/>
<!--TODO waiting HttpClient SSL impl <bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"/>-->
而且我记得这种CommonsClientHttpRequestFactory
forcommons-http-client-3.0
允许接受所有服务器证书。否则,您应该自定义HttpComponentsClientHttpRequestFactory
,commons-http-client-4.x
如下所示:
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()
在此答案中查看更多信息:如何忽略 Apache HttpClient 4.0 中的 SSL 证书错误。
在自定义之后,您只需将其注入clientHttpRequestFactory
到<int-http:outbound-gateway>
.