开发者

How to create a certificate with OpenSSL.net

开发者 https://www.devze.com 2023-02-28 20:51 出处:网络
I use C #. net in programming. My problem is using a OpenSSL.net to create certificate Personal and CA and signed personally c开发者_开发百科ertificate by a private key of CA.

I use C #. net in programming. My problem is using a OpenSSL.net to create certificate Personal and CA and signed personally c开发者_开发百科ertificate 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.


You can try this one also. Creating SSL X509 certificates using X509CertificateAuthority and X509Certificate classes. http://manmoahn-openssl-net.blogspot.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消