sjkp / letsencrypt-azure

The easiest way to use lets encrypt certificates on Azure
111 stars 35 forks source link

Execute RenewCertificate ok but not stored renewed certificate #33

Open M0nter0 opened 9 months ago

M0nter0 commented 9 months ago

Hello and thanks for sharing this code with the community.

I've deployed the template and it is running. Everyday the task runs AutoRenewCertificate successfully, but I've noticed the certificate in the KeyVault/Certificates is not replaced.

Trying to understand what is failing I've run the task manually, and checking the log in verbose mode I see the following (snippet simplified)

[Information] Executing 'AutoRenewCertificate' (Reason='This function was programmatically called via the host APIs.', Id={guid})
[Information] Renewing certificate at: 12/7/2023 2:20:14 PM
[Information] C# HTTP trigger function processed a request.
[Information] {} - Request: GET .... {{keyvaulturl}}/secrets...
[Information] Executed 'AutoRenewCertificate' (Succeeded, Id={guid}, Duration=13140ms)

Checking LetsEncrypt.cs I think it never runs it Task Run() as I don't see neither of the logs

if (cert == null || cert.Certificate.NotAfter < DateTime.UtcNow.AddDays(renewXNumberOfDaysBeforeExpiration)) //Cert doesnt exist or expires in less than renewXNumberOfDaysBeforeExpiration days, lets renew.
{
    logger.LogInformation("Certificate store didn't contain certificate or certificate was expired starting renewing");
    ...
}
else
{
    logger.LogInformation("Certificate expires in more than {renewXNumberOfDaysBeforeExpiration} days, reusing certificate from certificate store", renewXNumberOfDaysBeforeExpiration);
   ...
}

Am I missing something? How could I get more info about what is failing?

Thanks a lot