다음은 암호로 보호 된 .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));
}
참고 : 나는 어셈블리의 강력한 이름 생성을 지원하기 위해 여기에 (예를 들어, 비주얼 스튜디오 강력한 이름의 UI 양식)의 .NET Framework 도구에 의해 생성 된 PFX를 가정합니다. 어떤 PFX에서도 괜찮은 것은 아닙니다.
오류가 발생했을 때 사용한 코드를 표시하면 도움이됩니다. – poupou