readying for launch
This commit is contained in:
parent
9cd4be8bf6
commit
b965141dd2
|
@ -14,8 +14,8 @@ config.le.server = LE.stagingServer;
|
||||||
var le = LE.create(config.le);
|
var le = LE.create(config.le);
|
||||||
le.register({
|
le.register({
|
||||||
agreeTos: true
|
agreeTos: true
|
||||||
, domains: ['example.com'] // CHANGE TO YOUR DOMAIN
|
, domains: [process.argv[3] || 'example.com'] // CHANGE TO YOUR DOMAIN
|
||||||
, email: 'user@example.com' // CHANGE TO YOUR EMAIL
|
, email: process.argv[2] || 'user@example.com' // CHANGE TO YOUR EMAIL
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('[Error]: node-letsencrypt/examples/standalone');
|
console.error('[Error]: node-letsencrypt/examples/standalone');
|
||||||
|
|
|
@ -28,8 +28,6 @@ var bkDefaults = {
|
||||||
// backend-specific
|
// backend-specific
|
||||||
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
|
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
|
||||||
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
|
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
|
||||||
, text: true
|
|
||||||
, pythonClientPath: require('os').homedir() + '/.local/share/letsencrypt/bin/letsencrypt'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var le = LE.create(bkDefaults, {
|
var le = LE.create(bkDefaults, {
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
var binpath = require('homedir') + '/.local/share/letsencrypt/bin/letsencrypt';
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
|
|
||||||
plainPort: 80
|
plainPort: 80
|
||||||
|
@ -21,7 +19,6 @@ var config = {
|
||||||
// these are specific to the python client and won't be needed with the purejs library
|
// these are specific to the python client and won't be needed with the purejs library
|
||||||
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
|
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
|
||||||
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
|
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
|
||||||
, pythonClientPath: binpath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
5
index.js
5
index.js
|
@ -5,13 +5,14 @@
|
||||||
var PromiseA = require('bluebird');
|
var PromiseA = require('bluebird');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var tls = require('tls');
|
var tls = require('tls');
|
||||||
var path = require('path');
|
|
||||||
var leCore = require('./lib/letiny-core');
|
var leCore = require('./lib/letiny-core');
|
||||||
|
|
||||||
var LE = module.exports;
|
var LE = module.exports;
|
||||||
LE.productionServerUrl = leCore.productionServerUrl;
|
LE.productionServerUrl = leCore.productionServerUrl;
|
||||||
LE.stagingServer = leCore.stagingServerUrl;
|
LE.stagingServer = leCore.stagingServerUrl;
|
||||||
LE.configDir = leCore.configDir;
|
LE.configDir = leCore.configDir;
|
||||||
|
LE.logsDir = leCore.logsDir;
|
||||||
|
LE.workDir = leCore.workDir;
|
||||||
LE.acmeChallengPrefix = leCore.acmeChallengPrefix;
|
LE.acmeChallengPrefix = leCore.acmeChallengPrefix;
|
||||||
LE.knownEndpoints = leCore.knownEndpoints;
|
LE.knownEndpoints = leCore.knownEndpoints;
|
||||||
|
|
||||||
|
@ -204,7 +205,7 @@ LE.create = function (defaults, handlers, backend) {
|
||||||
cb(null, true);
|
cb(null, true);
|
||||||
}
|
}
|
||||||
, middleware: function () {
|
, middleware: function () {
|
||||||
var prefix = '/.well-known/acme-challenge/';
|
var prefix = leCore.acmeChallengePrefix;
|
||||||
|
|
||||||
return function (req, res, next) {
|
return function (req, res, next) {
|
||||||
if (0 !== req.url.indexOf(prefix)) {
|
if (0 !== req.url.indexOf(prefix)) {
|
||||||
|
|
|
@ -36,5 +36,5 @@ module.exports.getChallenge = function (args, key, done) {
|
||||||
module.exports.removeChallenge = function (args, key, done) {
|
module.exports.removeChallenge = function (args, key, done) {
|
||||||
//var hostname = args.domains[0];
|
//var hostname = args.domains[0];
|
||||||
|
|
||||||
fs.unlinkSync(path.join(args.webrootPath, key), done);
|
fs.unlink(path.join(args.webrootPath, key), done);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var PromiseA = require('bluebird');
|
var PromiseA = require('bluebird');
|
||||||
|
var mkdirpAsync = PromiseA.promisify(require('mkdirp'));
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var fs = PromiseA.promisifyAll(require('fs'));
|
var fs = PromiseA.promisifyAll(require('fs'));
|
||||||
|
var sfs = require('safe-replace');
|
||||||
|
|
||||||
var LE = require('../');
|
var LE = require('../');
|
||||||
var LeCore = PromiseA.promisifyAll(require('letiny-core'));
|
var LeCore = PromiseA.promisifyAll(require('letiny-core'));
|
||||||
|
@ -22,19 +24,13 @@ function getAcmeUrls(args) {
|
||||||
|
|
||||||
return LeCore.getAcmeUrlsAsync(args.server).then(function (data) {
|
return LeCore.getAcmeUrlsAsync(args.server).then(function (data) {
|
||||||
ipc.acmeUrlsUpdatedAt = Date.now();
|
ipc.acmeUrlsUpdatedAt = Date.now();
|
||||||
ipc.acmeUrls = {
|
ipc.acmeUrls = data;
|
||||||
newAuthz: data['new-authz']
|
|
||||||
, newCert: data['new-cert']
|
|
||||||
, newReg: data['new-reg']
|
|
||||||
, revokeCert: data['revoke-cert']
|
|
||||||
};
|
|
||||||
|
|
||||||
return ipc.acmeUrls;
|
return ipc.acmeUrls;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAccount(args, handlers) {
|
function createAccount(args, handlers) {
|
||||||
var mkdirpAsync = PromiseA.promisify(require('mkdirp'));
|
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
var localname = os.hostname();
|
var localname = os.hostname();
|
||||||
|
|
||||||
|
@ -45,14 +41,15 @@ function createAccount(args, handlers) {
|
||||||
|
|
||||||
return LeCore.registerNewAccountAsync({
|
return LeCore.registerNewAccountAsync({
|
||||||
email: args.email
|
email: args.email
|
||||||
, newReg: args._acmeUrls.newReg
|
, newRegUrl: args._acmeUrls.newReg
|
||||||
, debug: args.debug || handlers.debug
|
|
||||||
, agreeToTerms: function (tosUrl, agree) {
|
, agreeToTerms: function (tosUrl, agree) {
|
||||||
// args.email = email; // already there
|
// args.email = email; // already there
|
||||||
args.tosUrl = tosUrl;
|
args.tosUrl = tosUrl;
|
||||||
handlers.agreeToTerms(args, agree);
|
handlers.agreeToTerms(args, agree);
|
||||||
}
|
}
|
||||||
, accountPrivateKeyPem: pems.privateKeyPem
|
, accountPrivateKeyPem: pems.privateKeyPem
|
||||||
|
|
||||||
|
, debug: args.debug || handlers.debug
|
||||||
}).then(function (body) {
|
}).then(function (body) {
|
||||||
var accountDir = path.join(args.accountsDir, pems.publicKeyMd5);
|
var accountDir = path.join(args.accountsDir, pems.publicKeyMd5);
|
||||||
|
|
||||||
|
@ -144,21 +141,14 @@ function getCertificateAsync(account, args, defaults, handlers) {
|
||||||
var pyconf = PromiseA.promisifyAll(require('pyconf'));
|
var pyconf = PromiseA.promisifyAll(require('pyconf'));
|
||||||
|
|
||||||
return leCrypto.generateRsaKeypairAsync(args.rsaBitLength, args.rsaExponent).then(function (domain) {
|
return leCrypto.generateRsaKeypairAsync(args.rsaBitLength, args.rsaExponent).then(function (domain) {
|
||||||
return lef.getCertificateAsyncAsync({
|
return LeCore.getCertificateAsync({
|
||||||
newAuthorizationUrl: args._acmeUrls.newAuthz
|
newAuthzUrl: args._acmeUrls.newAuthz
|
||||||
, newCertificateUrl: args._acmeUrls.newCert
|
, newCertUrl: args._acmeUrls.newCert
|
||||||
|
|
||||||
, accountPrivateKeyPem: account.privateKeyPem
|
, accountPrivateKeyPem: account.privateKeyPem
|
||||||
, domainPrivateKeyPem: domain.privateKeyPem
|
, domainPrivateKeyPem: domain.privateKeyPem
|
||||||
, domains: args.domains
|
, domains: args.domains
|
||||||
|
|
||||||
/*
|
|
||||||
, getChallenge: function (domain, key, done) {
|
|
||||||
args.domains = [domain];
|
|
||||||
args.webrootPath = args.webrootPath || defaults.webrootPath;
|
|
||||||
handlers.getChallenge(args, key, done);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
, setChallenge: function (domain, key, value, done) {
|
, setChallenge: function (domain, key, value, done) {
|
||||||
args.domains = [domain];
|
args.domains = [domain];
|
||||||
args.webrootPath = args.webrootPath || defaults.webrootPath;
|
args.webrootPath = args.webrootPath || defaults.webrootPath;
|
||||||
|
@ -181,7 +171,7 @@ function getCertificateAsync(account, args, defaults, handlers) {
|
||||||
|
|
||||||
// TODO write to archive first, then write to live
|
// TODO write to archive first, then write to live
|
||||||
return mkdirpAsync(liveDir).then(function () {
|
return mkdirpAsync(liveDir).then(function () {
|
||||||
return PromisA.all([
|
return PromiseA.all([
|
||||||
sfs.writeFileAsync(certPath, result.cert, 'ascii')
|
sfs.writeFileAsync(certPath, result.cert, 'ascii')
|
||||||
, sfs.writeFileAsync(chainPath, result.chain, 'ascii')
|
, sfs.writeFileAsync(chainPath, result.chain, 'ascii')
|
||||||
, sfs.writeFileAsync(fullchainPath, result.fullchain, 'ascii')
|
, sfs.writeFileAsync(fullchainPath, result.fullchain, 'ascii')
|
||||||
|
@ -198,11 +188,13 @@ function getCertificateAsync(account, args, defaults, handlers) {
|
||||||
|
|
||||||
function registerWithAcme(args, defaults, handlers) {
|
function registerWithAcme(args, defaults, handlers) {
|
||||||
var pyconf = PromiseA.promisifyAll(require('pyconf'));
|
var pyconf = PromiseA.promisifyAll(require('pyconf'));
|
||||||
var server = args.server || defaults.server || LE.liveServer; // https://acme-v01.api.letsencrypt.org/directory
|
var server = args.server || defaults.server || LeCore.stagingServerUrl; // https://acme-v01.api.letsencrypt.org/directory
|
||||||
var acmeHostname = require('url').parse(server).hostname;
|
var acmeHostname = require('url').parse(server).hostname;
|
||||||
var configDir = args.configDir || defaults.configDir || LE.configDir;
|
var configDir = args.configDir || defaults.configDir || LE.configDir;
|
||||||
|
|
||||||
args.server = server;
|
args.server = server;
|
||||||
|
console.log('args.server');
|
||||||
|
console.log(server);
|
||||||
args.renewalDir = args.renewalDir || path.join(configDir, 'renewal', args.domains[0] + '.conf');
|
args.renewalDir = args.renewalDir || path.join(configDir, 'renewal', args.domains[0] + '.conf');
|
||||||
args.accountsDir = args.accountsDir || path.join(configDir, 'accounts', acmeHostname, 'directory');
|
args.accountsDir = args.accountsDir || path.join(configDir, 'accounts', acmeHostname, 'directory');
|
||||||
|
|
||||||
|
@ -212,7 +204,7 @@ function registerWithAcme(args, defaults, handlers) {
|
||||||
|
|
||||||
return accountId;
|
return accountId;
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if ("EENOENT" === err.code) {
|
if ("ENOENT" === err.code) {
|
||||||
return getAccountByEmail(args, handlers);
|
return getAccountByEmail(args, handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
"ursa": "^0.9.1"
|
"ursa": "^0.9.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-forge": "^0.6.38",
|
|
||||||
"bluebird": "^3.0.6",
|
"bluebird": "^3.0.6",
|
||||||
"homedir": "^0.6.0",
|
"homedir": "^0.6.0",
|
||||||
"letiny-core": "^1.0.1",
|
"letiny-core": "^1.0.1",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
|
"node-forge": "^0.6.38",
|
||||||
"pyconf": "^1.0.0",
|
"pyconf": "^1.0.0",
|
||||||
"request": "^2.67.0",
|
"request": "^2.67.0",
|
||||||
"safe-replace": "^1.0.0",
|
"safe-replace": "^1.0.2",
|
||||||
"serve-static": "^1.10.0"
|
"serve-static": "^1.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue