title: Cannot import pfx key file - Visual studio 2019
body: <p>I have a VSTO add-in which I'm migrating from VS2010 to visual studio 2019. However, I forgot the password to mypfx key attached to the main project of the solution.</p>
  <p>I'm now trying to create a new one and import it into my project to replace the old key which I can't use anymore. I've tried subsequent steps indicated on stackoverflow and other sites, but I keep getting the following build error in VS2019:</p>
  <pre><code>Cannot import the following key file: newtest.pfx. The key file may be password protected. 
  To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_10580C0D68F0E891  &lt;project name&gt;  
  </code></pre>
  <p>However, that's exactly what I'm trying. First, I create a new certificate as indicated <a href="http://woshub.com/how-to-create-self-signed-certificate-with-powershell/" rel="nofollow noreferrer">here</a>:</p>
  <pre><code>New-SelfSignedCertificate -DnsName &quot;somename&quot; -CertStoreLocation &quot;cert:\LocalMachine\My&quot;
  </code></pre>
  <p>Then I export it :</p>
  <pre><code>$CertPassword = ConvertTo-SecureString -String “somepass” -Force –AsPlainText    
  Export-PfxCertificate -Cert cert:\LocalMachine\My\&lt;somethumbprint&gt; -FilePath &lt;path&gt;/newtest.pfx -Password $CertPassword
  </code></pre>
  <p>Final step, as in <a href="https://stackoverflow.com/questions/23754044/strong-name-sn-exe-failed-to-install-key-pair-object-already-exists">this question</a> is to use sn.exe with the following command:</p>
  <pre><code>sn -i sg newtest.pfx VS_KEY_XXXXXXXXXXXX
  </code></pre>
  <p>The command runs successfully, but when I restart vs2019 again and open the add-in solution, the samen error pops up again. What can I do?</p>
  <p><strong>EDIT</strong>
  Also, I cannot uncheck the &quot;sign clickonce manifest&quot; checkbox in Project &gt; Properties &gt; Signing. THis means that the <strong>Select from store</strong> option as mentioned in the answer below is unavailable.
  I have moved this project to another computer, could that be the cause?</p>
  <p>A bit stuck here.</p>