如何随时强制更新greenlock-express证书?

How renew greenlock-express certificates forcefully at any time?

我在“greenlock.d/live/URL_PATH/”中有 CA 证书文件。它的到期日期是 2022 年 8 月。

但是我想马上续订,看看有没有续订。请建议我如何随时更新它们?

我做了什么:

我尝试了很多解决方案,例如:

代码:

app.js

'use strict';

var app = function(req, res) {
    res.end('Hello, Encrypted World!');
};

module.exports = app;

server.js

'use strict';

var beapp = require('./app.js');

require('greenlock-express')
    .init({
        packageRoot: __dirname,
        maintainerEmail: "EMAIL_ID",
        configDir: './greenlock.d',
        cluster: true
    })
    // .serve(beapp);
    .ready(httpsWorker);
function httpsWorker(glx) {
    var httpsServer = glx.httpsServer(null, beapp);
    httpsServer.listen(443, "0.0.0.0", function () {
        console.info("Listening on ", httpsServer.address());
    });
}

greenlock.d/config.json

{
  "defaults": {
    "store": {
      "basePath": "./greenlock.d",
      "module": "greenlock-store-fs"
    },
    "challenges": {
      "http-01": {
        "module": "acme-http-01-standalone"
      }
    },
    "renewOffset": "-45d",
    "renewStagger": "3d",
    "accountKeyType": "EC-P256",
    "serverKeyType": "RSA-2048",
    "subscriberEmail": "EMAIL_ID"
  },
  "sites": [
    {
      "subject": "URL_PATH",
      "altnames": [
        "URL_PATH"
      ],
      "renewAt": 1
    }
  ]
}
  • 运行 这些命令依次为:
  1. npm init
  2. npm install --save greenlock-express@v4
  3. npx greenlock init --config-dir ./greenlock.d --maintainer-email 'jon@example.com'
  4. npx greenlock add --subject example.com --altnames example.com
  5. node server.js

参考:https://www.npmjs.com/package/greenlock-express#1-create-your-project