【发布时间】:2014-04-06 00:26:49
【问题描述】:
我正在尝试使用 Bouncy Castle 生成证书,但我发现我似乎无法获得颁发证书的 AuthorityKeyIdentifier。我一直在尝试确定到底是什么问题,但到目前为止我不知道。
我正在检查的商店中的证书的授权密钥标识符为
KeyID=64 c1 59 db eb e7 2b f0 d7 e5 e3 81 77 d2 be b0
Certificate Issuer:
CN=Test Certification Authority
Certificate SerialNumber=5c 27 00 3b 0f 0a a2 83 4a 8d 2b d5 45 d2 9c 3f
然而,每当我在充气城堡中使用以下代码获取密钥时,它都会给我一个完全不同的 AKI:
var password = "p@ssw0rd1";
var file = File.ReadAllBytes(@"C:\somefilepath\TESTCA.pfx");
Pkcs12Store st = new Pkcs12Store(new MemoryStream(file), password.ToCharArray());
var alias = st.Aliases.Cast<string>().Where (s => st.IsKeyEntry(s)).Single();
var cert = (X509Certificate)st.GetCertificate(alias).Certificate;
var subjectPKI = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo( cert.GetPublicKey());
var aki = new AuthorityKeyIdentifier(subjectPKI);
BitConverter.ToString(aki.GetKeyIdentifier()).Replace("-"," ").Dump();
使用这个,我最终得到一个授权密钥标识符:
68 22 23 ED 45 82 A6 0E D6 A4 87 74 F2 E0 22 C4 4B F7 7D DF
但我在证书中找不到任何似乎与之匹配的信息。有什么想法吗?
【问题讨论】:
标签: c# security x509certificate bouncycastle x509