【问题标题】:Retrieve Private Key for the generated CSR检索生成的 CSR 的私钥
【发布时间】:2011-09-06 20:18:39
【问题描述】:

我正在使用 certenroll 对象创建 CSR。 主键是在同一台机器上创建的(Ccertificate store)。

如何为生成的 CSR 检索存储在本地存储中的主键。

【问题讨论】:

    标签: c# windows keystore private-key csr


    【解决方案1】:

    您可以从X509Certificate2.PrivateKey获取私钥。

    var store = new X509Store (StoreName.My, StoreLocation.CurrentUser);
    store.Open(OpenFlags.ReadOnly);
    
    var thumbprint = "AA99202885098B541C1ECD09C85351ED084A4A12";
    var certificate = store.Certificates.Find (X509FindType.FindByThumbprint, thumbprint, false) [0];
    
    var privateKey = (RSACryptoServiceProvider) certificate.PrivateKey;
    

    此外,X509Certificate 还提供导出为各种格式(包括 pfx)的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 2018-06-07
      • 2016-10-11
      • 2022-01-13
      • 2019-10-12
      相关资源
      最近更新 更多