从 PFX 证书中删除密码



我在 FPX 文件中使用 x509Certificate2 保护密码。我想创建一个函数,从中删除密码。

Stream CreatePFXWithoutPassword(string filenamePfx, string password)
{
...return new file
}

这可能吗?

当然,只需导入它,然后使用"no"密码(这实际上意味着空密码(再次导出它。

X509Certificate2Collection coll = new X509Certificate2Collection();
coll.Import(filename, password);
byte[] nopw = coll.Export(X509ContentType.Pfx);
// Optional: Clean up unnecessary resources.
foreach (X509Certificate2 cert in coll)
{
cert.Dispose();
}
return nopw;

最新更新