title: Ignore SSL Certificate in a Servlet
body: <p>I am getting the following exception:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I did some research and changed my connection code this:</p>
  
  <pre><code>SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
              public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                  return true;
              }
          }).build();
  
  CloseableHttpClient client = HttpClients.custom()
              .setRedirectStrategy(new LaxRedirectStrategy()) 
              .setSslcontext(sslContext)   
              .setConnectionManager(connMgr)
              .build();
  </code></pre>
  
  <p>This fixed the problem so far, I am no longer getting the exception and the connection works.</p>
  
  <p>The problem arises again when I use the same code in a Servlet running in Tomcat. </p>
  
  <p>Why ?</p>