v2.2.0: add bundle.pem and bugfix windows - nix symlinks and use full files

This commit is contained in:
AJ ONeal 2018-07-11 22:44:23 -06:00
parent cf9890e387
commit d7313d932a
2 changed files with 17 additions and 12 deletions

View File

@ -24,7 +24,6 @@ var writeFileAsync = util.promisify(fs.writeFile);
var statAsync = util.promisify(fs.stat); var statAsync = util.promisify(fs.stat);
var sfs = require('safe-replace'); var sfs = require('safe-replace');
var os = require('os'); var os = require('os');
var symlink = require('fs-symlink');
function log(debug) { function log(debug) {
if (debug) { if (debug) {
@ -137,6 +136,7 @@ var defaults = {
, fullchainPath: [ ':configDir', 'live', ':hostname', 'fullchain.pem' ].join(path.sep) , fullchainPath: [ ':configDir', 'live', ':hostname', 'fullchain.pem' ].join(path.sep)
, certPath: [ ':configDir', 'live', ':hostname', 'cert.pem' ].join(path.sep) , certPath: [ ':configDir', 'live', ':hostname', 'cert.pem' ].join(path.sep)
, chainPath: [ ':configDir', 'live', ':hostname', 'chain.pem' ].join(path.sep) , chainPath: [ ':configDir', 'live', ':hostname', 'chain.pem' ].join(path.sep)
, bundlePath: [ ':configDir', 'live', ':hostname', 'bundle.pem' ].join(path.sep)
, rsaKeySize: 2048 , rsaKeySize: 2048
}; };
@ -264,9 +264,8 @@ module.exports.create = function (configs) {
var certPath = args.certPath || pyobj.cert || path.join(liveDir, 'cert.pem'); var certPath = args.certPath || pyobj.cert || path.join(liveDir, 'cert.pem');
var fullchainPath = args.fullchainPath || pyobj.fullchain || path.join(liveDir, 'fullchain.pem'); var fullchainPath = args.fullchainPath || pyobj.fullchain || path.join(liveDir, 'fullchain.pem');
var chainPath = args.chainPath || pyobj.chain || path.join(liveDir, 'chain.pem'); var chainPath = args.chainPath || pyobj.chain || path.join(liveDir, 'chain.pem');
var privkeyPath = args.privkeyPath || pyobj.privkey var privkeyPath = args.privkeyPath || pyobj.privkey || args.domainKeyPath || path.join(liveDir, 'privkey.pem');
|| args.domainKeyPath var bundlePath = args.bundlePath || pyobj.bundle || path.join(liveDir, 'bundle.pem');
|| path.join(liveDir, 'privkey.pem');
var archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]); var archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]);
@ -275,6 +274,7 @@ module.exports.create = function (configs) {
var fullchainArchive = path.join(archiveDir, 'fullchain' + checkpoints + '.pem'); var fullchainArchive = path.join(archiveDir, 'fullchain' + checkpoints + '.pem');
var chainArchive = path.join(archiveDir, 'chain'+ checkpoints + '.pem'); var chainArchive = path.join(archiveDir, 'chain'+ checkpoints + '.pem');
var privkeyArchive = path.join(archiveDir, 'privkey' + checkpoints + '.pem'); var privkeyArchive = path.join(archiveDir, 'privkey' + checkpoints + '.pem');
var bundleArchive = path.join(archiveDir, 'bundle' + checkpoints + '.pem');
return mkdirpAsync(archiveDir).then(function () { return mkdirpAsync(archiveDir).then(function () {
return PromiseA.all([ return PromiseA.all([
@ -282,15 +282,19 @@ module.exports.create = function (configs) {
, sfs.writeFileAsync(chainArchive, pems.chain, 'ascii') , sfs.writeFileAsync(chainArchive, pems.chain, 'ascii')
, sfs.writeFileAsync(fullchainArchive, [ pems.cert, pems.chain ].join('\n'), 'ascii') , sfs.writeFileAsync(fullchainArchive, [ pems.cert, pems.chain ].join('\n'), 'ascii')
, sfs.writeFileAsync(privkeyArchive, pems.privkey, 'ascii') , sfs.writeFileAsync(privkeyArchive, pems.privkey, 'ascii')
, sfs.writeFileAsync(bundleArchive, pems.bundle, 'ascii')
]); ]);
}).then(function () { }).then(function () {
return mkdirpAsync(liveDir); return mkdirpAsync(liveDir);
}).then(function () { }).then(function () {
return PromiseA.all([ return PromiseA.all([
symlink(certArchive, certPath) sfs.writeFileAsync(certPath, pems.cert, 'ascii')
, symlink(chainArchive, chainPath) , sfs.writeFileAsync(chainPath, pems.chain, 'ascii')
, symlink(fullchainArchive, fullchainPath) // Most platforms need these two
, symlink(privkeyArchive, privkeyPath) , sfs.writeFileAsync(fullchainPath, [ pems.cert, pems.chain ].join('\n'), 'ascii')
, sfs.writeFileAsync(privkeyPath, pems.privkey, 'ascii')
// HAProxy needs "bundle.pem" aka "combined.pem"
, sfs.writeFileAsync(bundlePath, [ pems.privkey, pems.cert, pems.chain ].join('\n'), 'ascii')
]); ]);
}).then(function () { }).then(function () {
pyobj.checkpoints += 1; pyobj.checkpoints += 1;
@ -304,6 +308,8 @@ module.exports.create = function (configs) {
privkey: pems.privkey privkey: pems.privkey
, cert: pems.cert , cert: pems.cert
, chain: pems.chain , chain: pems.chain
, expires: pems.expires
, identifiers: pems.identifiers
/* /*
// TODO populate these only if they are actually known // TODO populate these only if they are actually known

View File

@ -1,6 +1,6 @@
{ {
"name": "le-store-certbot", "name": "le-store-certbot",
"version": "2.1.8", "version": "2.2.0",
"description": "The \"certbot\" storage strategy for Greenlock.js", "description": "The \"certbot\" storage strategy for Greenlock.js",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -27,9 +27,8 @@
"bluebird": "^3.5.1" "bluebird": "^3.5.1"
}, },
"dependencies": { "dependencies": {
"fs-symlink": "^1.2.1",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"pyconf": "^1.1.2", "pyconf": "^1.1.5",
"safe-replace": "^1.0.2" "safe-replace": "^1.0.3"
} }
} }