title: unable to find valid certification path to requested target PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException
body: <p>I have create a custom keystore file xyz.jsk, When I tried to using this file I am getting exception </p>
  
  <blockquote>
    <p>org.springframework.web.client.ResourceAccessException: I/O error on
    POST request for : sun.security.validator.ValidatorException: PKIX
    path building failed:
    sun.security.provider.certpath.SunCertPathBuilderException: unable to
    find valid certification path to requested target; nested exception is
    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</p>
  </blockquote>
  
  <pre><code>   String keyStorePassword = "NEWPASSWORD";
       KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
       ClassLoader classLoader = getClass().getClassLoader();
      //  File file = new 
     File(classLoader.getResource(keyStoreFile).getFile());
  
       File file = new File(dir, "xyz.jks");;
  
  
      keyStore.load(new FileInputStream(file), 
      keyStorePassword.toCharArray());
  
      SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
              new SSLContextBuilder()
                      .loadTrustMaterial(null, new TrustSelfSignedStrategy())
                      .loadKeyMaterial(keyStore, keyStorePassword.toCharArray())
                      .build(),
              NoopHostnameVerifier.INSTANCE);
  
      HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
  
          HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
          restTemplate.setRequestFactory(httpRequestFactory);
  
      ((HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory())
              .setConnectTimeout(Integer.parseInt(strTimeOut));
      ResponseEntity&lt;String&gt; responseEntity = restTemplate.exchange(urlPath, HttpMethod.POST, entity, clazz);
  </code></pre>