javaspring-boothttpclientspring-restspring-cloud-feign

Spring-cloud-starter-openfeign: SSL handshake exception with feign-httpclient


When trying to use feign-httpclient with Spring-cloud-starter-openfeign, I am getting SSL Handshake exception while the same code works if I don't use feign-httpclient.

I need to use feign-httpclient as I want to use the connection factory.

build.gradle

//on commenting the below dependency the code works fine.
compile('io.github.openfeign:feign-httpclient:9.4.0')
compile('org.springframework.cloud:spring-cloud-starter-openfeign')

Feign Client

@FeignClient(name = "testClient", url = "https://test:9820")
public interface TestClient {
@RequestMapping(method = RequestMethod.POST, value = "/test", consumes = "application/json", produces = "application/json")
TesteDto get(TestRequestDto testRequestDto);
}

Invocation Code:

 testClient.get(new TestRequestDto("test"));

application.yml

feign:
   client:
     config:
       default:
         connectTimeout: 5000
         readTimeout: 5000
         loggerLevel: full
  httpclient:
     maxConnections: 200
     maxConnectionsPerRoute: 200
     enabled: true

Exception:

javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target

Solution

  • What was required was the following configuration:

    feign:
       httpclient:
          disableSslValidation: true