Feign HTTPS 关闭SSL证书验证

方式一:
添加feign-httpclient依赖:

<dependency>
  <groupId>io.github.openfeign</groupId>
  <artifactId>feign-httpclient</artifactId>
</dependency>
feign.httpclient.disableSslValidation=true

如果是使用 okhttp,则必须使用另一个应用程序属性启用 okhttp 并添加 feign-okhttp 依赖项

feign.httpclient.disableSslValidation=true
feign.httpclient.enabled=false
feign.okhttp.enabled=true
>
    >io.github.openfeign>
    >feign-okhttp>
>

方式二:
eign.httpclient.disableSslValidation = true 不起作用的话:
启动参数:

-Dfeign.httpclient.disableSslValidation=true

方式三:

public class ClientConfiguration {

    @Bean
    public Client feignClient() {
        return new Client.Default(getSSLSocketFactory(), new NoopHostnameVerifier());
    }

    private SSLSocketFactory getSSLSocketFactory() {
        try {
            SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
            return sslContext.getSocketFactory();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

}

你可能感兴趣的:(springboot,https,ssl,spring,boot,spring,cloud)