title: java raises an SSLHandshakeException even if the root certificate in the trust store
body: <p>The following java code:</p>
  
  <pre><code>new URL("https://www.limagrain.com/").openStream()
  </code></pre>
  
  <p>raises the following error:</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException thrown: 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>However, the root certificate used by this site (<a href="https://www.thawte.com/roots/" rel="nofollow noreferrer">Thawte Primary Root CA - G3</a>) is present in java's trust store, and the site displays without problems in browsers.</p>
  
  <p>Checking the site on <a href="https://www.ssllabs.com/ssltest/analyze.html?d=limagrain.com" rel="nofollow noreferrer">Qualys SSL checker</a> gives a warning about an intermediate certificate marked as <em>extra download</em>.</p>
  
  <p>How to make java download the intermediate certificates automatically ?</p>