title: Extracting private key in Java from a [Trusted Root Certification Authorities\Local Computer] key store
body: <p>I would appreciate your assistance with a problem am facing while extracting a private key from a Windows <strong>[Trusted Root Certification Authorities\Local Computer]</strong> key store. I have this piece of code:</p>
  
  <pre><code>KeyStore keyStore = KeyStore.getInstance("Windows-ROOT");
  keyStore.load(null, null);
  String alias = "MyAlias";
  
  // Extract key associated with the specified alias
  Key key = keyStore.getKey(alias, null);
  Certificate cert = keyStore.getCertificate(alias);
  
  if (key instanceOf PrivateKey) {
      // Do stuff ...
  }
  </code></pre>
  
  <p>Here is the problem. The key gets extracted successfully when I am remotely logged in to production PC as &lt;Computer IP&gt;\Administrator BUT fails (i.e. <code>Key key = keyStore.getKey(alias, null);</code> returns <strong>null</strong>) when am remotely logged in as &lt;Domain&gt;\MyUserName. However, the certificate gets extracted successfully in both cases.</p>
  
  <p>It gets even more interesting. On my development PC, the key is extracted successfully BOTH when am logged in as local Administrator as well as when am logged in as &lt;Domain&gt;\MyUserName. </p>
  
  <p>On both production PC and development PC, certificate was installed with Administrator logged in. &lt;Domain&gt;\MyUserName is in the Administrators group on both development PC and production server. When the certificates were being installed, <em>Enable strong private key protection.</em> option was not checked.</p>