<pre lang="c#"> var privateKey = new PrivateKey(PrivateKey.KeySpecification.AtKeyExchange, 2048, false, true); var caCertificateRequest = new CaCertificateRequest(); string csr = caCertificateRequest.GenerateRequest("cn=test", privateKey); //Load signing certificate from MDM_pfx.pfx, this is generated using signingCertificatePrivate.pem and SigningCert.pem.pem using openssl var cert = new X509Certificate2(MY_MDM_PFX, PASSWORD, X509KeyStorageFlags.Exportable); //RSA provider to generate SHA1WithRSA var crypt = (RSACryptoServiceProvider)cert.PrivateKey; var sha1 = new SHA1CryptoServiceProvider(); byte[] data = Convert.FromBase64String(csr); byte[] hash = sha1.ComputeHash(data); //Sign the hash byte[] signedHash = crypt.SignHash(hash, CryptoConfig.MapNameToOID("SHA1")); var signedHashBytesBase64 = Convert.ToBase64String(signedHash);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)