title: keytool error: java.lang.Exception: Public keys in reply and keystore don't match
body: <p>I have this problem when I import a certification file into keystore:</p>
  
  <blockquote>
    <p>keytool error: java.lang.Exception: Public keys in reply and keystore don't match</p>
  </blockquote>
  
  <p>I do this this operation:</p>
  
  <p>1) create my keystore on the server :</p>
  
  <pre><code>keytool -genkey -keystore C:\keystore\keystore -alias jboss -keyalg RSA
  </code></pre>
  
  <p>2) I have domain.pfx and convert it whit this command:</p>
  
  <ul>
  <li><p>openssl pkcs12 -in domain.pfx -clcerts -nokeys -out domain.cer</p></li>
  <li><p>openssl pkcs12 -in domain.pfx -nocerts -nodes  -out domain_encrypted.key</p></li>
  <li><p>openssl rsa -in domain_encrypted.key -out domain.key</p></li>
  </ul>
  
  <p>Now I have 3 new files:</p>
  
  <ul>
  <li>domain.cer</li>
  <li>domain_encrypted.key</li>
  <li>domain.key</li>
  </ul>
  
  <p>3) In the end, Import the domain.cer into C:\keystore\keystore in the jboss alias:</p>
  
  <pre><code>keytool -import -alias jboss -keystore C:\keystore\keystore -file C:\cert\domain.cer
  </code></pre>
  
  <p>But I have this error:</p>
  
  <blockquote>
    <p>keytool error: java.lang.Exception: Public keys in reply and keystore don't match</p>
  </blockquote>
  
  <p>What is the problem?</p>