title: How to install a certificate to personal store without password?
body: <p>I am kind of new to certificates and all that stuff.</p>
  
  <p>I have a web application that sends a https request by iframe (it has to be https due to the application itself is also https) to a .NET application running on the client which has an HttpListener listening on <a href="https://localhost:[port]" rel="nofollow">https://localhost:[port]</a> so the client app can receive a "do something now" from a browser click.</p>
  
  <p>When I install the client app, I install the *.crt file to the Root-Store and bind it to our port:</p>
  
  <pre><code>X509Certificate2 certificateFromCrtFile = new X509Certificate2(X509Certificate2.CreateFromCertFile(crtPath));
  X509Store rootStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
  rootStore.Open(OpenFlags.ReadWrite);
  rootStore.Add(certificateFromCrtFile);
  rootStore.Close();
  
  string crtThumbprint = certificateFromCrtFile.Thumbprint;
  string netshParams = string.Format("http add sslcert ipport=0.0.0.0:[port] certhash={0} appid={{{1}}}", crtThumbprint, Guid.NewGuid());
  Utilities.StartProcess("netsh.exe", Environment.SystemDirectory, netshParams, true, true);
  </code></pre>
  
  <p>Now, before that, I have to install the certificate also in the personal store because my "server" in that case is the HttpListener on the same client.</p>
  
  <p>Okay, so I could do it the following way:</p>
  
  <pre><code>X509Certificate2 certificateFromPfxFile = new X509Certificate2(pfxPath, "pwd");
  X509Store personalStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
  personalStore.Open(OpenFlags.ReadWrite);
  personalStore.Add(certificateFromPfxFile);
  personalStore.Close();
  </code></pre>
  
  <p>In this case I have to write the *.pfx password in clear text in code.
  And if I understood correctly, with this password you can easily get the private key, right?</p>