【问题标题】:Remove password from PFX certificate从 PFX 证书中删除密码
【发布时间】:2019-09-06 04:18:20
【问题描述】:

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

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

这可能吗?

【问题讨论】:

    标签: c# certificate x509certificate2


    【解决方案1】:

    好的,只需导入它,然后用“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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-12
      • 2012-01-22
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 2020-10-10
      • 2012-06-06
      相关资源
      最近更新 更多