readying for launch

This commit is contained in:
AJ ONeal 2015-12-16 10:07:00 +00:00
parent 9cd4be8bf6
commit b965141dd2
7 changed files with 22 additions and 34 deletions

View File

@ -14,8 +14,8 @@ config.le.server = LE.stagingServer;
var le = LE.create(config.le);
le.register({
agreeTos: true
, domains: ['example.com'] // CHANGE TO YOUR DOMAIN
, email: 'user@example.com' // CHANGE TO YOUR EMAIL
, domains: [process.argv[3] || 'example.com'] // CHANGE TO YOUR DOMAIN
, email: process.argv[2] || 'user@example.com' // CHANGE TO YOUR EMAIL
}, function (err) {
if (err) {
console.error('[Error]: node-letsencrypt/examples/standalone');

View File

@ -28,8 +28,6 @@ var bkDefaults = {
// backend-specific
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
, text: true
, pythonClientPath: require('os').homedir() + '/.local/share/letsencrypt/bin/letsencrypt'
};
var le = LE.create(bkDefaults, {

View File

@ -2,8 +2,6 @@
var path = require('path');
var binpath = require('homedir') + '/.local/share/letsencrypt/bin/letsencrypt';
var config = {
plainPort: 80
@ -21,7 +19,6 @@ var config = {
// these are specific to the python client and won't be needed with the purejs library
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
, pythonClientPath: binpath
}
};

View File

@ -5,13 +5,14 @@
var PromiseA = require('bluebird');
var crypto = require('crypto');
var tls = require('tls');
var path = require('path');
var leCore = require('./lib/letiny-core');
var LE = module.exports;
LE.productionServerUrl = leCore.productionServerUrl;
LE.stagingServer = leCore.stagingServerUrl;
LE.configDir = leCore.configDir;
LE.logsDir = leCore.logsDir;
LE.workDir = leCore.workDir;
LE.acmeChallengPrefix = leCore.acmeChallengPrefix;
LE.knownEndpoints = leCore.knownEndpoints;
@ -204,7 +205,7 @@ LE.create = function (defaults, handlers, backend) {
cb(null, true);
}
, middleware: function () {
var prefix = '/.well-known/acme-challenge/';
var prefix = leCore.acmeChallengePrefix;
return function (req, res, next) {
if (0 !== req.url.indexOf(prefix)) {

View File

@ -36,5 +36,5 @@ module.exports.getChallenge = function (args, key, done) {
module.exports.removeChallenge = function (args, key, done) {
//var hostname = args.domains[0];
fs.unlinkSync(path.join(args.webrootPath, key), done);
fs.unlink(path.join(args.webrootPath, key), done);
};

View File

@ -1,8 +1,10 @@
'use strict';
var PromiseA = require('bluebird');
var mkdirpAsync = PromiseA.promisify(require('mkdirp'));
var path = require('path');
var fs = PromiseA.promisifyAll(require('fs'));
var sfs = require('safe-replace');
var LE = require('../');
var LeCore = PromiseA.promisifyAll(require('letiny-core'));
@ -22,19 +24,13 @@ function getAcmeUrls(args) {
return LeCore.getAcmeUrlsAsync(args.server).then(function (data) {
ipc.acmeUrlsUpdatedAt = Date.now();
ipc.acmeUrls = {
newAuthz: data['new-authz']
, newCert: data['new-cert']
, newReg: data['new-reg']
, revokeCert: data['revoke-cert']
};
ipc.acmeUrls = data;
return ipc.acmeUrls;
});
}
function createAccount(args, handlers) {
var mkdirpAsync = PromiseA.promisify(require('mkdirp'));
var os = require("os");
var localname = os.hostname();
@ -45,14 +41,15 @@ function createAccount(args, handlers) {
return LeCore.registerNewAccountAsync({
email: args.email
, newReg: args._acmeUrls.newReg
, debug: args.debug || handlers.debug
, newRegUrl: args._acmeUrls.newReg
, agreeToTerms: function (tosUrl, agree) {
// args.email = email; // already there
args.tosUrl = tosUrl;
handlers.agreeToTerms(args, agree);
}
, accountPrivateKeyPem: pems.privateKeyPem
, debug: args.debug || handlers.debug
}).then(function (body) {
var accountDir = path.join(args.accountsDir, pems.publicKeyMd5);
@ -144,21 +141,14 @@ function getCertificateAsync(account, args, defaults, handlers) {
var pyconf = PromiseA.promisifyAll(require('pyconf'));
return leCrypto.generateRsaKeypairAsync(args.rsaBitLength, args.rsaExponent).then(function (domain) {
return lef.getCertificateAsyncAsync({
newAuthorizationUrl: args._acmeUrls.newAuthz
, newCertificateUrl: args._acmeUrls.newCert
return LeCore.getCertificateAsync({
newAuthzUrl: args._acmeUrls.newAuthz
, newCertUrl: args._acmeUrls.newCert
, accountPrivateKeyPem: account.privateKeyPem
, domainPrivateKeyPem: domain.privateKeyPem
, 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) {
args.domains = [domain];
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
return mkdirpAsync(liveDir).then(function () {
return PromisA.all([
return PromiseA.all([
sfs.writeFileAsync(certPath, result.cert, 'ascii')
, sfs.writeFileAsync(chainPath, result.chain, 'ascii')
, sfs.writeFileAsync(fullchainPath, result.fullchain, 'ascii')
@ -198,11 +188,13 @@ function getCertificateAsync(account, args, defaults, handlers) {
function registerWithAcme(args, defaults, handlers) {
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 configDir = args.configDir || defaults.configDir || LE.configDir;
args.server = server;
console.log('args.server');
console.log(server);
args.renewalDir = args.renewalDir || path.join(configDir, 'renewal', args.domains[0] + '.conf');
args.accountsDir = args.accountsDir || path.join(configDir, 'accounts', acmeHostname, 'directory');
@ -212,7 +204,7 @@ function registerWithAcme(args, defaults, handlers) {
return accountId;
}, function (err) {
if ("EENOENT" === err.code) {
if ("ENOENT" === err.code) {
return getAccountByEmail(args, handlers);
}

View File

@ -37,14 +37,14 @@
"ursa": "^0.9.1"
},
"dependencies": {
"node-forge": "^0.6.38",
"bluebird": "^3.0.6",
"homedir": "^0.6.0",
"letiny-core": "^1.0.1",
"mkdirp": "^0.5.1",
"node-forge": "^0.6.38",
"pyconf": "^1.0.0",
"request": "^2.67.0",
"safe-replace": "^1.0.0",
"safe-replace": "^1.0.2",
"serve-static": "^1.10.0"
}
}