public static void GenerateSslCertificate(PfxData pfx, Org.BouncyCastle.Security.SecureRandom random) { string curveName = "curve25519"; curveName = "secp256k1"; // IIS does not support Elliptic Curve... // Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair certKeyPair = KeyGenerator.GenerateEcKeyPair(curveName, random); Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair certKeyPair = KeyGenerator.GenerateRsaKeyPair(2048, random); // Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair certKeyPair = KeyGenerator.GenerateDsaKeyPair(1024, random); // Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair certKeyPair = KeyGenerator.GenerateDHKeyPair(1024, random); // Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair certKeyPair = KeyGenerator.GenerateGostKeyPair(4096, random); Org.BouncyCastle.X509.X509Certificate sslCertificate = SelfSignSslCertificate(random, pfx.Certificate, certKeyPair.Public, pfx.PrivateKey); bool val = CerGenerator.ValidateSelfSignedCert(sslCertificate, pfx.Certificate.GetPublicKey()); // SSL (string Private, string Public)certKeys = KeyPairToPem(certKeyPair); PfxFile.Create(@"obelix.pfx", sslCertificate, certKeyPair.Private, ""); WriteCerAndCrt(sslCertificate, @"obelix"); System.IO.File.WriteAllText(@"obelix_private.key", certKeys.Private, System.Text.Encoding.ASCII); // System.IO.File.WriteAllText(@"obelix_public.key", certKeys.Public, System.Text.Encoding.ASCII); string pemCert = ToPem(sslCertificate); System.IO.File.WriteAllText(@"obelix.pem", pemCert, System.Text.Encoding.ASCII); } // End Sub GenerateSslCertificate
} // End Sub SetRegistry public static void CreateSslCertificate() { Org.BouncyCastle.Security.SecureRandom random = new Org.BouncyCastle.Security.SecureRandom(NonBackdooredPrng.Create()); // 1. Root certificate to pfx // 2. Read root certificate // 3. Sign SSL certificate // chrome://settings/certificates?search=certifi PfxData pfx = GenerateRootCertificate(random); // PfxData pfx = PfxFile.Read("skynet.pfx"); GenerateSslCertificate(pfx, random); }