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