0

I'm trying to figure out how to create an X.509 certificate containing a self-signed DSA public key (SSK) in C#.

Having given up on the native C# crypto library which doesn't seem to allow this, I've been looking at the Bouncy Castle library.

However despite a description to the contrary, the download doesn't contain any docs.

I have been wading through the library classes but there are a lot!

I just need to generate a random key pair, sign them and save them in a certificate file.

Has anyone done this and are you able to point me to a good example, or even maybe supply an example?

Thanks for your help!

CompanyDroneFromSector7G
  • 4,291
  • 13
  • 54
  • 97

2 Answers2

1

We successfully did this a while back (but ended up needing to use "non self signed certificates") We based our implementation on the following example from Doug E. Cook. http://blogs.msdn.com/b/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx?PageIndex=2

Wonderbird
  • 392
  • 4
  • 12
  • That's a really good start, thanks! Any idea how to save it to a valid X509 cert file? – CompanyDroneFromSector7G Oct 30 '13 at 20:35
  • byte[] baCert = CreateSelfSignCertificatePfx( "CN=MYCERT", DateTime.Now, DateTime.Now + TimeSpan.FromDays(3650), "MyCertPW"); File.WriteAllBytes("c:\\myCertFile.pfx", baCert); (If working off the example in the previously referenced link) – Wonderbird Oct 30 '13 at 21:02
  • That's exactly what I did! And your answer is correct. I just need to convert the pfx to a crt format, but that's another question. Thanks :) – CompanyDroneFromSector7G Oct 30 '13 at 21:11
1

I've been generating self signed RSA certificates with Bouncy castle, this should let you start your own experiments:

http://www.wiktorzychla.com/2012/12/how-to-create-x509certificate2.html

Wiktor Zychla
  • 47,367
  • 6
  • 74
  • 106