有没有办法将 Org.BouncyCaSTLe.X509.X509Certificate
转换为 System.Security.Cryptography.X509Certificates.X509Certificate2
?
逆向操作很简单,将Org.BouncyCaSTLe.X509.X509CertificateParser
与
System.Security.Cryptography.X509Certificates.X509Certificate2.Export()
。
最佳答案
简单!!
using B = Org.BouncyCastle.X509; //Bouncy certificates
using W = System.Security.Cryptography.X509Certificates;
W.X509Certificate2 certificate = new W.X509Certificate2(pdfCertificate.GetEncoded());
现在我可以在服务器中验证证书链了:
W.X509Chain ch = new W.X509Chain();
ch.ChainPolicy.RevocationMode = W.X509RevocationMode.NoCheck;
if (!ch.Build(certificate))
res |= ErroresValidacion.CAInvalida;
可用于验证使用 iTextSharp 提取的 pdf 证书。
关于c# - 如何将 BouncyCaSTLe X509Certificate 转换为 X509Certificate2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8136651/