OpenSSL.NET C # Certification X509 Wrapper

Hi, I am using the OpenSSL.NET shell in my C # project. I want to create an X509 certification, but I do not know this procedure. what it should contain (what parameters) ... etc. this is my code, I did it after looking at some tests:

        OpenSSL.X509.X509Certificate x509 = new OpenSSL.X509.X509Certificate();
        OpenSSL.Crypto.RSA rsa = new OpenSSL.Crypto.RSA();
        rsa.GenerateKeys(1024, 0x10001, null, null);
        OpenSSL.Crypto.CryptoKey key = new OpenSSL.Crypto.CryptoKey(rsa);
        OpenSSL.Crypto.MessageDigestContext digest = new OpenSSL.Crypto.MessageDigestContext(
                                                                 OpenSSL.Crypto.MessageDigest.SHA1);

I believe that the certificate should accept the RSA private key and digest as parameters, and I should configure it (date parameters ... and others). Can someone help me with this? finish my code? thank.

+3
source share
1 answer

I am using the following procedure:

// Initialize the following with your information
var serial = 1234;
var issuer = new X509Name("issuer");
var subject = new X509Name("subject");

// Creates the key pair
var rsa = new RSA();
rsa.GenerateKeys(1024, 0x10001, null, null);

// Creates the certificate
var key = new CryptoKey(rsa);
var cert = new X509Certificate(serial, subject, issuer, key, DateTime.Now, DateTime.Now.AddYears(20));

// Dumps the certificate into a .cer file
var bio = BIO.File("C:/temp/cert.cer", "w");
cert.Write(bio);
+2
source

All Articles