Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to check validity of certificate #28

Closed
DaemonBeast opened this issue Apr 6, 2020 · 2 comments
Closed

Add option to check validity of certificate #28

DaemonBeast opened this issue Apr 6, 2020 · 2 comments

Comments

@DaemonBeast
Copy link

DaemonBeast commented Apr 6, 2020

Issue has been abandoned - revised issue: #30

Abandoned due to flaw: If the old certificate was retrieved, it would not match the newly generated key and would result in an error

Please can you add another option to the client.auto() function called renewIfExpired.

It will have the following properties:

  • string data type.
    • contains the directory path of a certificate.
  • return value:
    • if the certificate in the specified directory has expired, a new certificate is returned.
    • if the certificate in the specified directory is still valid, it is returned.
  • default value: null (new certificate is always generated).
  • prevents the rate limit from being reached from unnecessary repeated certificate requests.
  • allows the user to use their own certificate and have node-acme-client as a fallback to generate a certificate in case their certificate expires.

Possible Implementation

if (renewIfExpired) {
    if (fs.existsSync(renewIfExpired)) {
        var cert = fs.readFileSync(renewIfExpired);
        var expiry = (new Date((await ACME.forge.readCertificateInfo(cert)).notAfter)).valueOf();
        var time = (new Date()).valueOf();

        if (expiry >= time) {
            return cert;
        }
    } else {
        // ERROR: file does not exist
    }
}

// Continue certificate generation

By the way, thank you so much for such a great package!
I really appreciate the sophisticated code, clear documentation and constant bug fixes (all of the other major ACME clients are either really complicated or have serious bugs).

@DaemonBeast DaemonBeast changed the title Add option to save files after creation Add option to check validity of certificate Apr 7, 2020
@Trackhe
Copy link

Trackhe commented Apr 10, 2020

+1

@DaemonBeast
Copy link
Author

Issue has been abandoned - revised issue: #30

Abandoned due to flaw: If the old certificate was retrieved, it would not match the newly generated key and would result in an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants