title: Java Keytool error after importing certificate , "keytool error: java.io.FileNotFoundException & Access Denied"
body: <p>I'm trying to connect a Java Web API via HTTPS; however, an exception is thrown:</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
  </code></pre>
  
  <p>I followed these steps which I learned from online keytool &amp; SSL cert tutorials:</p>
  
  <ol>
  <li><p>I copied the HTTPS URL into the browser, downloaded the SSL certificates &amp; Installed them in the browser using Internet Explorer.</p></li>
  <li><p>Exported the certificates to a path on my computer, the certificates were saved as <code>.cer</code></p></li>
  <li><p>Used the keytool's import option. The command below executed without any errors.</p>
  
  <pre><code>keytool -import -alias downloadedCertAlias -keystore C:\path\to\my\keystore\cacerts.file -file C:\path\of\exportedCert.cer
  </code></pre></li>
  <li><p>I was prompted for a password at the command prompt, which I entered then I was authenticated. </p></li>
  <li><p>The <code>cmd</code> window printed some certificate data &amp; signatures and I was prompted with the question:  </p>
  
  <blockquote>
    <p>Trust this certificate?</p>
  </blockquote>
  
  <p>I answered yes.</p></li>
  <li><p>The cmd prompt displayed </p>
  
  <blockquote>
    <p>Certificate was added to keystore</p>
  </blockquote>
  
  <p>However after that message, another exception was displayed:</p>
  
  <pre><code>keytool error: java.io.FileNotFoundException: C:\Program files\...\cacerts &lt;Access Denied&gt;
  </code></pre></li>
  </ol>
  
  <p>Finally when I checked the keystore , the SSL certificate was not added and my application gives the same exception I was getting earlier when trying to connect:</p>
  
  <pre><code>(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException)
  </code></pre>