如何将BouncyCastle X509Certificate转换为X509Certificate2? [英] How can I convert a BouncyCastle X509Certificate to an X509Certificate2?

查看:485
本文介绍了如何将BouncyCastle X509Certificate转换为X509Certificate2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将 Org.BouncyCastle.X509.X509Certificate 转换为 System.Security.Cryptography.X509Certificates.X509Certificate2

逆操作很简单,将$ code> Org.BouncyCastle.X509.X509CertificateParser 与$ b $合并b System.Security.Cryptography.X509Certificates.X509Certificate2.Export()

The inverse operation is easy, combining Org.BouncyCastle.X509.X509CertificateParser with 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();
certificate.Import(pdfCertificate.GetEncoded());

现在我可以验证服务器中的证书链:

And now I can validate certificate chain in the server:

W.X509Chain ch = new W.X509Chain();
ch.ChainPolicy.RevocationMode = W.X509RevocationMode.NoCheck;
if (!ch.Build(certificate))
   res |= ErroresValidacion.CAInvalida; 

用于验证用iTextSharp提取的pdf证书。

Useful to validate pdf certifcates extracted with iTextSharp.

这篇关于如何将BouncyCastle X509Certificate转换为X509Certificate2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆