Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting X509Certificate2 certificate into BouncyCastle X509Certificate

Tags:

c#

I have an object of System.Security.Cryptography.X509Certificates.X509Certificate2. I need to convert it into an object of Org.BouncyCastle.X509.X509Certificate.

Can anyone help me please?

like image 254
habibalsaki Avatar asked Dec 10 '12 10:12

habibalsaki


2 Answers

Use Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate, which takes a System.Security.Cryptography.X509Certificates.X509Certificate and returns a Org.BouncyCastle.X509.X509Certificate.

like image 166
Martin Eden Avatar answered Sep 24 '22 08:09

Martin Eden


It's been a while since I played with Bouncy Castle. Basically take X509Certificate2.RawData and pass it to the BC X509Certificate constructor.

If I remember correctly, BC has a Org.BouncyCastle.Security.DotNetUtilities. This should allow you to import a certificate.

like image 42
Richard Schneider Avatar answered Sep 23 '22 08:09

Richard Schneider