【发布时间】:2022-11-22 08:13:54
【问题描述】:
从 Azure Keyvault 下载证书版本时,我无法获得完整的证书链。附:我在 .Net Framework 4.7.2 上。
当我手动将下载的证书导入到本地存储,然后将其导出到带有密码的文件时。稍后访问证书,如果我在 C# 中加载该证书,我可以获得完整的链。
有没有办法直接从 Keyvault 获取完整链?
这是代码片段。
DownloadCertificateOptions downloadCertOptions = new DownloadCertificateOptions(certificateProperties.Name);
downloadCertOptions.Version = certificateProperties.Version;
downloadCertOptions.KeyStorageFlags = X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet;
cert = CertificateClient.DownloadCertificate(downloadCertOptions);
byte[] exportedCert = cert.Export(X509ContentType.Pfx);
//byte[] exportedCert = cert.Export(X509ContentType.Pkcs12);
X509Certificate2Collection certificates = new X509Certificate2Collection();
string password = "";
X509Certificate2Collection collection - certificates.Import(rawData, password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
Console.WriteLine($"Collection has {collection.Count} certs");
**期望 3 个证书(子证书、中级证书和根证书)**,但只得到一个(子证书)。
【问题讨论】:
标签: c# azure-keyvault x509certificate2