コード例 #1
0
        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);
            }
        }
コード例 #2
0
 protected void RemoveOldCertificate()
 {
     CertRegistration.RemoveCert(StoreName.My, websiteName);
     CertRegistration.RemoveCert(StoreName.AuthRoot, websiteName);
 }