title: How to get the private key from the files generated while creating CSR (one .cer and one .keystore file)?
body: <p>I have generated the CSR request on our wintel server ( we need to bind our application hosted on this server for Https) using below commands in keytool:</p>
  
  <pre><code>Keytool -genkey -alias &lt;server name&gt; -keyalg RSA -keysize 2048 -keystore &lt;server name&gt;.keystore
      Enter keystore password - changeit
      Confirm the password – changeit
      Common Name: ******
      Organization: ***
      Organization Unit: **
      Locality: ****
      State: ***
      Country: **
      Enter key password or hit enter to keep same as keystore password
  
  keytool -certreq -keyalg RSA -alias &lt;server name&gt; -file certreq.csr -keystore &lt;server name&gt;.keystore
  </code></pre>
  
  <p>Two files are generated </p>
  
  <ul>
  <li>certreq.cer</li>
  <li>.keystore</li>
  </ul>
  
  <p>I send the two files to the concerned team, they got the SSL certificate and installed it on the same server.</p>
  
  <p>Now the certificate is there in <code>console root\certificates (local computer)\personal\certificates</code> but its not appearing in IIS for binding. The team is now asking me for the private key to resolve the issue.</p>
  
  <p>Can someone let me how to get the private key from the .cer and .keystore file?
  And if you can point out the reason why certificate is not appearing in IIS and how to resolve it, I would really appreacite that.</p>
  
  <p>P.S: I am not sure if this is the right place for this question. Help me out to know the right place if this is not.</p>
  
  <p>Edit: For someone stuck with same questions, check out the answer 
   by garethTheRed here- <a href="https://serverfault.com/questions/943496/how-to-install-cer-and-p7b-certificates-to-use-in-iis/943500#943500">https://serverfault.com/questions/943496/how-to-install-cer-and-p7b-certificates-to-use-in-iis/943500#943500</a><br>
  In my case, the certificate received from CA was directly installed, thats why it was not private key verified, and was not appearing in IIS also. We had to import the public key(the .cer file) to the keystore </p>
  
  <pre><code>keytool -importcert -file certificate.cer -keystore &lt;server name&gt;.keystore -alias &lt;server name&gt;
  </code></pre>
  
  <p>and then convert the keystore to a PKCS#12, with:</p>
  
  <pre><code>keytool -importkeystore -srckeystore &lt;server name&gt;.keystore -destkeystore &lt;server name&gt;.pfx -srcstoretype JKS - deststoretype PKCS12 -deststorepass &lt;new password&gt;
  </code></pre>
  
  <p>Then we imported the pfx in certificate store.</p>