パスワードで保護された.PFXファイルからStrongNameKeyPairオブジェクトを作成するC#コードです:
public static StrongNameKeyPair GetStrongNameKeyPairFromPfx(string pfxFile, string password)
{
X509Certificate2Collection certs = new X509Certificate2Collection();
certs.Import(pfxFile, password, X509KeyStorageFlags.Exportable);
if (certs.Count == 0)
throw new ArgumentException(null, "pfxFile");
RSACryptoServiceProvider provider = certs[0].PrivateKey as RSACryptoServiceProvider;
if (provider == null) // not a good pfx file
throw new ArgumentException(null, "pfxFile");
return new StrongNameKeyPair(provider.ExportCspBlob(false));
}
注:私は、アセンブリに厳密な名前の作成をサポートするために、ここで(例えばVisual Studioの厳密な名前のUIフォーム).NET Frameworkのツールで作成されたPFXを前提としています。どのPFXでもOKではないかもしれません。
エラーを取得するために使用したコードを表示すると、それが役立つでしょう。 – poupou