static void Main(string[] args) { Ports = new List <int>(); ReadCommonName(false); ReadPort(false); CertUtils.BindSslPort(CommonName, Ports); Console.WriteLine("Succeed!"); Console.WriteLine(); Console.WriteLine("Do you want to export this certificate to file? Press Y to export and other key to skip ..."); if (Console.ReadLine().ToString().ToLower() == "y") { var filePath = CertUtils.ExportToFile(); Console.WriteLine("Export to file succeed: "); Console.WriteLine(filePath); Console.WriteLine(); } else { Console.WriteLine("Skipped."); Console.WriteLine(); } Console.WriteLine("Application will exist in 5 seconds ..."); System.Threading.Thread.Sleep(5 * 1000); }
public static void BindSslPort(string subjectName, List <int> ports) { SUBJECTNAME = subjectName; if (string.IsNullOrEmpty(SUBJECTNAME)) { Console.WriteLine("Invalid common name!"); return; } RemoveExistsCerts(); certificate = CertUtils.CreateSelfSignedCertificate(); AddCertToAuthRoot(); foreach (var port in ports) { BindSslPort(port); } }