Skip to content

Commit

Permalink
Use certificate validFrom and validTo vs. cert order
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Apr 25, 2023
1 parent a4f1cd5 commit 06c04cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/lib/lets-encrypt.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import https from 'https';
import { X509Certificate } from 'crypto';
import dnsPromises from 'dns/promises';
import acme from 'acme-client';

Expand Down Expand Up @@ -424,12 +425,16 @@ class LetsEncrypt {
const [certificate, ...chainArray] = acme.crypto.splitPemChain(fullChain);
const chain = chainArray.join('');

// Parse out the date info for the certificate, which are going to be strings:
// { validFrom: 'Apr 24 17:52:54 2023 GMT', validTo: 'Apr 24 17:52:54 2028 GMT' }
const { validFrom, validTo } = new X509Certificate(certificate);

return {
privateKey: key.toString(),
certificate,
chain,
validFrom: new Date(),
validTo: new Date(this.#order.expires!),
validFrom: new Date(validFrom),
validTo: new Date(validTo),
};
};

Expand Down

0 comments on commit 06c04cd

Please sign in to comment.