From a6b1b5cfa687050375b72832a91e51e1ed2f40d9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 20 Dec 2015 03:31:05 +0000 Subject: [PATCH] minor fixes --- lib/accounts.js | 13 ++++++++----- lib/core.js | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/accounts.js b/lib/accounts.js index c24745c..d8db0b4 100644 --- a/lib/accounts.js +++ b/lib/accounts.js @@ -64,6 +64,7 @@ function createAccount(args, handlers) { pems.privateKey = pems.privateKeyJwk; pems.regr = regr; pems.accountId = accountId; + pems.id = accountId; return pems; }); }); @@ -99,25 +100,27 @@ function getAccount(accountId, args, handlers) { return !files[key].error; })) { // TODO log renewal.conf - console.warn("Account '" + accountId + "' was currupt. No big deal (I think?). Creating a new one..."); + console.warn("Account '" + accountId + "' was corrupt. No big deal (I think?). Creating a new one..."); + //console.log(accountId, files); return createAccount(args, handlers); } return leCrypto.privateJwkToPemsAsync(files.private_key).then(function (keypair) { files.accountId = accountId; // preserve current account id + files.id = accountId; files.publicKeySha256 = keypair.publicKeySha256; files.publicKeyMd5 = keypair.publicKeyMd5; files.publicKeyPem = keypair.publicKeyPem; // ascii PEM: ----BEGIN... files.privateKeyPem = keypair.privateKeyPem; // ascii PEM: ----BEGIN... - files.privateKeyJson = keypair.private_key; // json { n: ..., e: ..., iq: ..., etc } - files.privateKeyJwk = keypair.private_key; // json { n: ..., e: ..., iq: ..., etc } + files.privateKeyJson = keypair.privateKeyJwk; // json { n: ..., e: ..., iq: ..., etc } + files.privateKeyJwk = keypair.privateKeyJwk; // json { n: ..., e: ..., iq: ..., etc } return files; }); }); } -function getAccountIdByEmail(args, handlers) { +function getAccountIdByEmail(args) { // If we read 10,000 account directories looking for // just one email address, that could get crazy. // We should have a folder per email and list @@ -171,7 +174,7 @@ function getAccountIdByEmail(args, handlers) { }).then(function (accountId) { return accountId; }, function (err) { - if ('ENOENT' == err.code) { + if ('ENOENT' === err.code) { // ignore error return null; } diff --git a/lib/core.js b/lib/core.js index 9f9e5f1..d27eabb 100644 --- a/lib/core.js +++ b/lib/core.js @@ -54,10 +54,15 @@ function writeCertificateAsync(result, args, defaults, handlers) { var certPath = args.certPath || obj.cert || path.join(liveDir, 'cert.pem'); var fullchainPath = args.fullchainPath || obj.fullchain || path.join(liveDir, 'fullchain.pem'); var chainPath = args.chainPath || obj.chain || path.join(liveDir, 'chain.pem'); - var privkeyPath = args.domainPrivateKeyPath || args.domainKeyPath - || obj.privkey || obj.keyPath + var privkeyPath = args.privkeyPath || obj.privkey + //|| args.domainPrivateKeyPath || args.domainKeyPath || obj.keyPath || path.join(liveDir, 'privkey.pem'); + if (args.debug) { + console.log('################ privkeyPath ################'); + console.log(privkeyPath); + } + var archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]); var checkpoint = obj.checkpoint.toString(); @@ -86,7 +91,9 @@ function writeCertificateAsync(result, args, defaults, handlers) { obj.checkpoint += 1; var updates = { - cert: certPath + account: args.accountId || args.account.id + + , cert: certPath , privkey: privkeyPath , chain: chainPath , fullchain: fullchainPath @@ -107,7 +114,6 @@ function writeCertificateAsync(result, args, defaults, handlers) { // TODO XXX end // yes, it's an array. weird, right? , webrootPath: args.webrootPath && [args.webrootPath] || [] - , account: args.account.accountId , server: args.server || args.acmeDiscoveryUrl , logsDir: args.logsDir }; @@ -156,7 +162,6 @@ function getCertificateAsync(account, args, defaults, handlers) { } args.domainPrivateKeyPem = domainKey.privateKeyPem; - args.account = account; //args.registration = domainKey; return LeCore.getCertificateAsync({ @@ -321,8 +326,8 @@ module.exports.create = function (defaults, handlers) { console.log('[LE DEBUG] reg domains', args.domains); } return getOrCreateAcmeAccount(copy, defaults, handlers).then(function (account) { - console.log('AAAAAAAAAACCCCCCCCCCCCCCCCOOOOOOOOOOOOOOUUUUUUUUUUUUUUUNNNNNNNNNNNNNNNNTTTTTTTTTTTT'); - console.log(account); + console.log("account", account); + args.account = account; return getOrCreateDomainCertificate(account, copy, defaults, handlers); }); }