Create a signed crypt32.dll certificate

I want to create certificates programmatically in C # .net that are signed by CA. I was able to create a self-signed certificate with CertCreateSelfSignCertificate as described here: http://msdn.microsoft.com/en-us/library/aa376039(VS.85).aspx Self -signed certificate in Windows without makecert?

I was looking through the MSDN documentation and I cannot find the function to create the certificate and sign it from the request. Most of the features seem to be designed to manage the certificate store. Am I barking the wrong dll here?

+3
source share
3 answers

. BouncyCastle :

var keygen = new RsaKeyPairGenerator();
keygen.Init(new KeyGenerationParameters(new SecureRandom(), 2048));

var keys = keygen.GenerateKeyPair();

var certGen = new X509V3CertificateGenerator();
var dnName = new X509Name("CN=Test CA");

certGen.SetSerialNumber(BigInteger.ValueOf(1));
certGen.SetIssuerDN(dnName);
certGen.SetNotBefore(DateTime.Today);
certGen.SetNotAfter(DateTime.Today.AddYears(10));
certGen.SetSubjectDN(dnName);
certGen.SetPublicKey(keys.Public);
certGen.SetSignatureAlgorithm("SHA1WITHRSA");

var cert = certGen.Generate(keys.Private);

, - . . DER (.cer) PKCS12 (.p12).

+5
+1

. makecert.exe , : CryptSignAndEncodeCertificate http://msdn.microsoft.com/en-us/library/aa380277(VS.85).aspx

+1

Source: https://habr.com/ru/post/1706538/


All Articles