繁体   English   中英

使用 BouncyCastle 创建基于自签名根证书颁发的证书

[英]Creating certificate issued based on self-signed root certificate with BouncyCastle

我一直在使用这个 repo ,它允许创建基于自签名根证书的证书。

我的根证书以 MyCARoot.cer 和 MyCARoot.pvk 的形式提供给我。它们是之前使用 makecert 创建(并已部署)的。 因此,为了让我使用上述链接中的代码,我必须使用 pvk2pfx.exe 在 .pfx 中组合 .cer 和 .pvk 文件

我的问题是,生成证书并将其导入到个人存储后,它似乎无效。 在 MMC 的认证路径选项卡上,它说:

找不到证书的颁发者

注意:我对代码所做的唯一更改是使用的密码。

该来源的问题在于它应该这样做:

X509Certificate issueCert = Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate(issuerCertificate);
var authorityKeyIdentifier = new AuthorityKeyIdentifierStructure(issueCert);
certificateGenerator.AddExtension(X509Extensions.AuthorityKeyIdentifier.Id, false, authorityKeyIdentifier);

而不是这个:

var authorityKeyIdentifierExtension =
new AuthorityKeyIdentifier(
    SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(issuerKeyPair.Public),
    new GeneralNames(new GeneralName(issuerDN)),
    issuerSerialNumber);

certificateGenerator.AddExtension(
    X509Extensions.AuthorityKeyIdentifier.Id, false, authorityKeyIdentifierExtension);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM