title: Making a strongly named COM interop assembly with a PFX file
body: <p>I am trying to create a strongly named COM interop assembly with a PFX file.<br>
  TlbImp.exe is perfectly happy with an SNK file created using "sn.exe -k" (which contains both public and private keys), but the problem is that I have a PFX file...<br>
  I can export the public key from PFX to SNK using sn.exe -p, but it only exports the public key, which TlbImp.exe does not like at all. Can I export both public and private keys?<br><br>
  I tried to install the PFX file using <br>
  sn.exe -i MyCompany.pfx xyz <br>
  and then import the type library using <br>
  TlbImp.exe /keycontainer:xyz ...", <br>
  but that gives me <br>
  TlbImp : error TI0000 : Invalid strong name parameters specified.</p>
  
  <p>What can I do?<br>
  Thank you!</p>
  
  <p><strong>UPDATE</strong>: Oleg's answer and his utility below work perfectly. 
  The PFX file (after it is re-exported) can be successfully used to extract the 
  public key (<em>sn.exe -p</em>) to be used it with tlbimp.exe (<em>tlbimp.exe&nbsp; 
  /publickey:xyz.pub</em>). The PFX file can then be used to re-sign the interop 
  dll (<em>sn.exe -R</em>)</p>
  
  <p>Comodo really did drop the ball on this one. Below is the dump (<em>certutil.exe 
  -dump -v xyz.pfx</em>) of the original and fixed PFX files:</p>
  
  <p>&nbsp;</p>
  
  <p><strong>Before:</strong></p>
  
  <p>CERT_KEY_PROV_INFO_PROP_ID(2):<br />
  Key Container = {36BDD7BD-F295-47B2-B9E7-C25BD5B4313E}<br />
  Unique container name: 
  bf63afd9ba3fb912ccd3423c6486e5fc_25e0623f-f712-49e2-abda-f31f014b5dae<br />
  Provider = Microsoft Enhanced Cryptographic Provider v1.0<br />
  ProviderType = 1<br />
  Flags = 0<br />
  <strong>KeySpec = 1 -- AT_KEYEXCHANGE</strong><br />
  ...<br />
  Private Key:<br />
  PRIVATEKEYBLOB<br />
  Version: 2<br />
  <strong>aiKeyAlg: 0xa400</strong><br />
  <strong>CALG_RSA_KEYX</strong><br />
  Algorithm Class: <strong>0xa000(5) ALG_CLASS_KEY_EXCHANGE</strong><br />
  Algorithm Type: 0x400(2) ALG_TYPE_RSA<br />
  Algorithm Sub-id: 0x0(0) ALG_SID_RSA_ANY<br />
  &nbsp;</p>
  
  <p><strong>After:</strong></p>
  
  <p>CERT_KEY_PROV_INFO_PROP_ID(2):<br />
  Key Container = {DBA6454E-F6D2-4F0B-AB1B-9E4F7C0E139C}<br />
  Unique container name: 
  d2d09f87081c1af7c4225889f1af2250_25e0623f-f712-49e2-abda-f31f014b5dae<br />
  Provider = Microsoft Enhanced Cryptographic Provider v1.0<br />
  ProviderType = 1<br />
  Flags = 0<br />
  <strong>KeySpec = 2 -- AT_SIGNATURE</strong><br />
  ...<br />
  Private Key:<br />
  PRIVATEKEYBLOB<br />
  Version: 2<br />
  <strong>aiKeyAlg: 0x2400</strong><br />
  <strong>CALG_RSA_SIGN</strong><br />
  Algorithm Class: <strong>0x2000(1) ALG_CLASS_SIGNATURE</strong><br />
  Algorithm Type: 0x400(2) ALG_TYPE_RSA<br />
  Algorithm Sub-id: 0x0(0) ALG_SID_RSA_ANY<br />
  </p>