protected void Renew() { log.Clear(); try { RemoveOldCertificate(); bool ok = StartCertificateServer(); if (ok) { server.Start(GetLocalIP()); Process p = LaunchAcmeDotNet(websiteName, certPassword); p.Exited += (snd, args) => { server.Stop(); // Unfortunately, we don't get an exit code on error. // int ret = p.ExitCode; if (!log.ToString().Contains("acme:error:")) { if (registrationMethod == CertRegistrationMethod.NETSH) { CertRegistration.Register(websiteName, certPassword, s => log.AppendLine(s)); if (log.ToString().Contains("SSL Certificate successfully added")) { success = true; } else { success = false; } } } else { success = false; } RegistrationResult?.Invoke(this, EventArgs.Empty); }; } } catch (Exception ex) { success = false; log.AppendLine(ex.Message); RegistrationResult?.Invoke(this, EventArgs.Empty); } }
protected void RemoveOldCertificate() { CertRegistration.RemoveCert(StoreName.My, websiteName); CertRegistration.RemoveCert(StoreName.AuthRoot, websiteName); }