feign client禁用ssl证书校验

2023-10-16 16:33:54 浏览数 (2)

访问一些只有自签名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证书验证

0 人点赞