} // proc NewCertificate private async Task <bool> GenerateAsync(AcmeStateStore state) { var r = await state.GetChallengeStateAsync(); if (r != "valid") { Log.Info("State is '{0}', expected is 'valid'.", r); return(false); } // read certificate Log.Info("Generate key."); var pfxData = await state.GenerateKeyAsync(); // install certificate in store await UpdateCertificateAsync(state, pfxData); return(true); } // func GenerateAsync
} // func TryGetState #endregion #region -- NewCertificate, Generate, Update ----------------------------------- private async Task <bool> NewCertificateAsync(AcmeStateStore state, bool force) { var notAfter = force ? DateTime.MinValue : GetCurrentCertifcateNotAfter(state.CommonName); if (notAfter < DateTime.Now || notAfter.AddDays(-10) < DateTime.Now) { // create a new order Log.Info("Start new Order."); await state.NewOrderAsync(); // wait one second await Task.Delay(1000); // start validation process await state.GetChallengeStateAsync(); return(true); } else { return(false); } } // proc NewCertificate