I use C #. net in programming. My problem is using a OpenSSL.net to create certificate Personal and CA and signed personally certificate by a private key of CA.
I have already managed the integrated OpenSSL.net in my project, but I can not find the line of code to create the certificate.
How do I create a certificate with OpenSSL.net?
Try this one:
X509Name issuer = new X509Name("issuer");
X509Name subject = new X509Name("subject");
RSA rsa = new RSA();
rsa.GenerateKeys(512,0x10021,null,null);
CryptoKey key = new CryptoKey(rsa);
X509Certificate cert = new X509Certificate(123, subject, issuer, key, DateTime.Now,
DateTime.Now.AddDays(200));
File.WriteAllText("C:\\temp\\public.txt",rsa.PublicKeyAsPEM);
File.WriteAllText("C:\\temp\\private.txt", rsa.PrivateKeyAsPEM);
BIO bio = BIO.File("C:/temp/cert.cer", "w");
cert.Write(bio);
X509Certificate is creating a certificate; cert.Write writes this certificate to a file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With