访问一些只有自签名ssl证书的API时,会抛出异常:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
,所以需要feign client可以禁用ssl证书校验
httpclient客户端
- 引入
feign-httpclient
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>12.3</version>
</dependency>
- 禁用ssl校验:
application.yml
feign:
httpclient:
disable-ssl-validation: false
okhttp客户端
- 引入
feign-okhttp
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>12.3</version>
</dependency>
- 禁用ssl校验:
application.yml
feign:
httpclient:
disable-ssl-validation: true
okhttp:
enabled: true
参考
- Feign HTTPS 关闭SSL证书验证