1

I started using https instead of http in my microservice architecture application. When a request is made with Feign Client, it uses http instead of https.

I created the following class which configures ssl for Feign but it is not working.

@Bean
    public Feign.Builder feignBuilder() throws Exception {
        return Feign.builder()
                .retryer(Retryer.NEVER_RETRY)
                .client(feignClient());
    }

    private SSLSocketFactory createSSLContext() throws Exception {
        String trustStorePath = "/home/kaan/NetBeansProjects/SociMedia/BlockService/src/main/resources/truststore.jks";
        String keyStorePath = "/home/kaan/NetBeansProjects/SociMedia/BlockService/src/main/resources/keystore.jks";
        String pass = "pass";
        KeyStore keyStore = KeyStore.getInstance("JKS"); 
        keyStore.load(new FileInputStream(ResourceUtils.getFile(keyStorePath)), pass.toCharArray());

        SSLContext context = SSLContextBuilder.create()
                .loadTrustMaterial(ResourceUtils.getFile(trustStorePath), pass.toCharArray())
                .loadKeyMaterial(keyStore, pass.toCharArray())
                .build();
        return context.getSocketFactory();
    }

    @Bean
    public Client feignClient() throws Exception {
        return new Client.Default(createSSLContext(), org.apache.http.conn.ssl.SSLConnectionSocketFactory.getDefaultHostnameVerifier());
    }


    @Bean
    public Decoder feignDecoder(ObjectFactory<HttpMessageConverters> converters) {
        return new ResponseEntityDecoder(new SpringDecoder(converters));
    }


    @Bean
    public Encoder feignEncoder() {
        return new SpringFormEncoder();
    }

I use this class every feign client interface as configuration parameter.

When I access the https://192.168.1.59:9090/v1/user/get?id=2 endpoint, I get the following error:

BlockService executing GET http://BlockService/v1/block/blocked?userId1=25&userId2=2 feign.RetryableException: BlockService executing GET http://BlockService/v1/block/blocked?userId1=25&userId2=2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.