title: keytool : Certificate import gives error message - Keystore was tampered with, or password was incorrect
body: <p><strong>My goal is to generate a certificate, export it in a file and import in JDK keystore.</strong></p>
  
  <p>In first step I have generated a self signed certificate using following command, providing password as 'password' for keystore and key:</p>
  
  <pre><code>keytool   -genkeypair  -keystore .keystore  -alias uasera  -keyalg RSA
  </code></pre>
  
  <p>In second step I exported the certificate using similar password and following command:</p>
  
  <pre><code>keytool  -exportcert  -keystore  .keystore  -alias usera  -file usera.crt
  </code></pre>
  
  <p><strong>NOW!</strong></p>
  
  <p>I am trying to import this certificate in cacerts in JDK using similar password and following command but getting exception.</p>
  
  <pre><code>keytool -importcert -file usera.crt -keypass password  -keystore "C:\Program Files\Java\jdk1.7.0_13\jre\lib\security\cacerts"
  </code></pre>
  
  <p><strong>ERROR</strong></p>
  
  <p>K:\java\certificates>keytool -importcert -file usera.crt -keypass password  -keystore "C:\Program Files\Java\jdk1.7.0_13\jre\lib\security\cacerts"
  Enter keystore password:
  keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect</p>