Refactor GreenlockUtil challengeCreateFn and challengeRemoveFn to improve readability

This commit is contained in:
Simon Larsen 2024-04-30 14:16:35 +01:00
parent 2ba406f802
commit 78b7252743
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
2 changed files with 12 additions and 4 deletions

View File

@ -124,7 +124,11 @@ export default class GreenlockUtil {
email: LetsEncryptNotificationEmail.toString(), email: LetsEncryptNotificationEmail.toString(),
termsOfServiceAgreed: true, termsOfServiceAgreed: true,
challengePriority: ['http-01'], // only http-01 challenge is supported by oneuptime challengePriority: ['http-01'], // only http-01 challenge is supported by oneuptime
challengeCreateFn: async (authz: acme.Authorization, challenge: Challenge , keyAuthorization: string) => { challengeCreateFn: async (
authz: acme.Authorization,
challenge: Challenge,
keyAuthorization: string
) => {
// Satisfy challenge here // Satisfy challenge here
/* http-01 */ /* http-01 */
if (challenge.type === 'http-01') { if (challenge.type === 'http-01') {
@ -141,7 +145,10 @@ export default class GreenlockUtil {
}); });
} }
}, },
challengeRemoveFn: async (authz: acme.Authorization, challenge: Challenge) => { challengeRemoveFn: async (
authz: acme.Authorization,
challenge: Challenge
) => {
// Clean up challenge here // Clean up challenge here
if (challenge.type === 'http-01') { if (challenge.type === 'http-01') {
@ -160,7 +167,9 @@ export default class GreenlockUtil {
}); });
// get expires at date from certificate // get expires at date from certificate
const cert: acme.CertificateInfo = await acme.forge.readCertificateInfo(certificate); const cert: acme.CertificateInfo = await acme.forge.readCertificateInfo(
certificate
);
const issuedAt: Date = cert.notBefore; const issuedAt: Date = cert.notBefore;
const expiresAt: Date = cert.notAfter; const expiresAt: Date = cert.notAfter;

View File

@ -45,7 +45,6 @@ export default class Jobs {
logger.error(err); logger.error(err);
} }
// Write to disk. // Write to disk.
await LocalFile.write( await LocalFile.write(
`/etc/nginx/certs/StatusPageCerts/${cert.domain}.crt`, `/etc/nginx/certs/StatusPageCerts/${cert.domain}.crt`,