Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting Certificate (with privatekey) in Root, LocalMachine certificate store fails in .NET 4
    primarykey
    data
    text
    <p>I'm having problems inserting a new CA certificate with privatekey in the Root certificate store of the localmachine. </p> <p>This is what happens:</p> <pre><code>//This doesn't help either. new StorePermission (PermissionState.Unrestricted) { Flags = StorePermissionFlags.AddToStore }.Assert(); var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine); privkey.PersistKeyInCsp = true; //This shouldn't be necessary doesn't make a difference what so ever. RSACryptoServiceProvider.UseMachineKeyStore = true; cert.PrivateKey = privkey; store.Open (OpenFlags.MaxAllowed); store.Add (cert); store.Close (); </code></pre> <p>The certificate gets inserted and it all looks dandy: (see!) <img src="https://i.stack.imgur.com/eOtPT.png" alt="note it says it has a private key"></p> <p>Note: is says it has a privatekey.</p> <p>So you'd say one would be able to find it with <a href="http://msdn.microsoft.com/en-us/library/ms732026.aspx" rel="nofollow noreferrer">FindPrivateKey</a> </p> <pre><code>C:\Users\Administrator\Desktop&gt;FindPrivateKey.exe Root LocalMachine -t "54 11 b1 f4 31 99 19 d3 5a f0 5f 01 95 fc aa 6f 71 12 13 eb" FindPrivateKey failed for the following reason: Unable to obtain private key file name Use /? option for help </code></pre> <p>It's cute .... BUT IT'S WRONG!! (2 stupid dogs reference)</p> <p>And the Certificate export dialog gives me this very fine message: <img src="https://i.stack.imgur.com/WiYKn.png" alt="alt text"></p> <p>This code is run while impersonating an administrator using this snippet: <a href="http://www.codeproject.com/KB/cs/zetaimpersonator.aspx" rel="nofollow noreferrer">click here</a></p> <p>I'd just love to know WHY?</p> <p>(tested on Windows Server 2008 R2 &amp; Windows 7)</p> <p>I'll be damned!</p> <p><strong>It works when I compile it to v3.5!!!!</strong></p> <p>What to do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload