Checks the certificate on every domain in your sheet each morning and emails the ones running out of time to renew.
Uses
Gmail
Google Sheets
Warn before SSL certificates expire
domainSheetUrl to blank.Set domainSheetUrl to blank.domainSheetTab to blank.Set domainSheetTab to blank.certificateApiUrl to blank.Set certificateApiUrl to blank.alertEmail to blank.Set alertEmail to blank.warnWithinDays to 30.Set warnWithinDays to 30.domainSheetUrl. Save it as domainSheet.Read the rows of domainSheetUrl. Save it as domainSheet.sites to domainSheet.rows.Set sites to domainSheet.rows.expiringSoon to an empty list.Set expiringSoon to an empty list.couldNotCheck to an empty list.Set couldNotCheck to an empty list.site in sites:For each site in sites:domain to blank.Set domain to blank.missingDomainIf a step below fails, save the error as missingDomainTry
site.Domain and save it as domain.Trim site.Domain and save it as domain.On error
domain to blank.Change domain to blank.domain is emptyIf domain is emptyYes
No
No steps
daysLeft to 0.Set daysLeft to 0.expiresOn to blank.Set expiresOn to blank.wasChecked to false.Set wasChecked to false.checkFailedIf a step below fails, save the error as checkFailedTry
certificateApiUrl plus domain and save it as certificate.Fetch certificateApiUrl plus domain and save it as certificate.certificate.body.result.valid_till and save it as expiryDate.Trim certificate.body.result.valid_till and save it as expiryDate.expiryDate and save it as daysLeft.Count the days from today's date to expiryDate and save it as daysLeft.expiresOn to expiryDate.Change expiresOn to expiryDate.wasChecked to true.Change wasChecked to true.On error
domain - checkFailed.message with certificateApiUrl replaced by the endpoint address to the end of couldNotCheck and save it as couldNotCheck.Add domain - checkFailed.message with certificateApiUrl replaced by the endpoint address to the end of couldNotCheck and save it as couldNotCheck.wasChecked is yes and daysLeft is less than or equal to warnWithinDaysIf wasChecked is yes and daysLeft is less than or equal to warnWithinDaysYes
daysLeft is less than 0If daysLeft is less than 0Yes
domain - EXPIRED on expiresOn to the end of expiringSoon and save it as expiringSoon.Add domain - EXPIRED on expiresOn to the end of expiringSoon and save it as expiringSoon.No
domain - expires on expiresOn (daysLeft days left) to the end of expiringSoon and save it as expiringSoon.Add domain - expires on expiresOn (daysLeft days left) to the end of expiringSoon and save it as expiringSoon.No
No steps
report to blank.Set report to blank.expiringSoon isn't emptyIf expiringSoon isn't emptyYes
report to Certificates expiring within warnWithinDays days:Change report to Certificates expiring within warnWithinDays days:
expiringSoon joined by a new line
.No
No steps
couldNotCheck isn't emptyIf couldNotCheck isn't emptyYes
report to reportChange report to report
These sites could not be checked:
couldNotCheck joined by a new line
.No
No steps
report is emptyIf report is emptyYes
warnWithinDays more days.Finish the run: Every certificate checked is valid for more than warnWithinDays more days.No
No steps
alertEmail.Send an email to alertEmail.
Subject: SSL certificate check: the length of expiringSoon expiring within warnWithinDays daysreport