0

I have a working solution that creates valid .pfx files (based on CryptoAPI being wrapped in C#). I can import this into my private tore, then export it to a .cer

HOWEVER (isnt there always a however?) what I can not do is generate the appropriate .cer file from code. OpenSSL (or any other third party elements) are not an option for this environment, neither is anything that requires a manual/GUI type operation....

I am sure the function exists in the API (CertMgr.msc must call "Something" when it does the magic...but two days of searching have yielded nothing.

tshepang
  • 12,111
  • 21
  • 91
  • 136
David V. Corbin
  • 344
  • 1
  • 10

1 Answers1

0

A poor mans answer (I would very much a lower level)

// create the pfx byte stream... byte[] selfSigned = CertificateCreator.CreateSelfSignCertificatePfx(distinguishedName, new DateTime(2013, 4, 1), new DateTime(2013, 12, 31), insecurePassword);

// crate a certificate instance X509Certificate2 cert = new X509Certificate2(selfSigned, insecurePassword);

// export as .cer [DER] selfSigned = cert.Export(X509ContentType.Cert);

// write to file.. System.IO.File.WriteAllBytes(certificateFilename+".cer"), selfSigned);

David V. Corbin
  • 344
  • 1
  • 10