minor fixes

This commit is contained in:
AJ ONeal 2015-12-20 03:31:05 +00:00
parent 9b84d88a8c
commit a6b1b5cfa6
2 changed files with 20 additions and 12 deletions

View File

@ -64,6 +64,7 @@ function createAccount(args, handlers) {
pems.privateKey = pems.privateKeyJwk; pems.privateKey = pems.privateKeyJwk;
pems.regr = regr; pems.regr = regr;
pems.accountId = accountId; pems.accountId = accountId;
pems.id = accountId;
return pems; return pems;
}); });
}); });
@ -99,25 +100,27 @@ function getAccount(accountId, args, handlers) {
return !files[key].error; return !files[key].error;
})) { })) {
// TODO log renewal.conf // 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 createAccount(args, handlers);
} }
return leCrypto.privateJwkToPemsAsync(files.private_key).then(function (keypair) { return leCrypto.privateJwkToPemsAsync(files.private_key).then(function (keypair) {
files.accountId = accountId; // preserve current account id files.accountId = accountId; // preserve current account id
files.id = accountId;
files.publicKeySha256 = keypair.publicKeySha256; files.publicKeySha256 = keypair.publicKeySha256;
files.publicKeyMd5 = keypair.publicKeyMd5; files.publicKeyMd5 = keypair.publicKeyMd5;
files.publicKeyPem = keypair.publicKeyPem; // ascii PEM: ----BEGIN... files.publicKeyPem = keypair.publicKeyPem; // ascii PEM: ----BEGIN...
files.privateKeyPem = keypair.privateKeyPem; // ascii PEM: ----BEGIN... files.privateKeyPem = keypair.privateKeyPem; // ascii PEM: ----BEGIN...
files.privateKeyJson = keypair.private_key; // json { n: ..., e: ..., iq: ..., etc } files.privateKeyJson = keypair.privateKeyJwk; // json { n: ..., e: ..., iq: ..., etc }
files.privateKeyJwk = keypair.private_key; // json { n: ..., e: ..., iq: ..., etc } files.privateKeyJwk = keypair.privateKeyJwk; // json { n: ..., e: ..., iq: ..., etc }
return files; return files;
}); });
}); });
} }
function getAccountIdByEmail(args, handlers) { function getAccountIdByEmail(args) {
// If we read 10,000 account directories looking for // If we read 10,000 account directories looking for
// just one email address, that could get crazy. // just one email address, that could get crazy.
// We should have a folder per email and list // We should have a folder per email and list
@ -171,7 +174,7 @@ function getAccountIdByEmail(args, handlers) {
}).then(function (accountId) { }).then(function (accountId) {
return accountId; return accountId;
}, function (err) { }, function (err) {
if ('ENOENT' == err.code) { if ('ENOENT' === err.code) {
// ignore error // ignore error
return null; return null;
} }

View File

@ -54,10 +54,15 @@ function writeCertificateAsync(result, args, defaults, handlers) {
var certPath = args.certPath || obj.cert || path.join(liveDir, 'cert.pem'); var certPath = args.certPath || obj.cert || path.join(liveDir, 'cert.pem');
var fullchainPath = args.fullchainPath || obj.fullchain || path.join(liveDir, 'fullchain.pem'); var fullchainPath = args.fullchainPath || obj.fullchain || path.join(liveDir, 'fullchain.pem');
var chainPath = args.chainPath || obj.chain || path.join(liveDir, 'chain.pem'); var chainPath = args.chainPath || obj.chain || path.join(liveDir, 'chain.pem');
var privkeyPath = args.domainPrivateKeyPath || args.domainKeyPath var privkeyPath = args.privkeyPath || obj.privkey
|| obj.privkey || obj.keyPath //|| args.domainPrivateKeyPath || args.domainKeyPath || obj.keyPath
|| path.join(liveDir, 'privkey.pem'); || 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 archiveDir = args.archiveDir || path.join(args.configDir, 'archive', args.domains[0]);
var checkpoint = obj.checkpoint.toString(); var checkpoint = obj.checkpoint.toString();
@ -86,7 +91,9 @@ function writeCertificateAsync(result, args, defaults, handlers) {
obj.checkpoint += 1; obj.checkpoint += 1;
var updates = { var updates = {
cert: certPath account: args.accountId || args.account.id
, cert: certPath
, privkey: privkeyPath , privkey: privkeyPath
, chain: chainPath , chain: chainPath
, fullchain: fullchainPath , fullchain: fullchainPath
@ -107,7 +114,6 @@ function writeCertificateAsync(result, args, defaults, handlers) {
// TODO XXX end // TODO XXX end
// yes, it's an array. weird, right? // yes, it's an array. weird, right?
, webrootPath: args.webrootPath && [args.webrootPath] || [] , webrootPath: args.webrootPath && [args.webrootPath] || []
, account: args.account.accountId
, server: args.server || args.acmeDiscoveryUrl , server: args.server || args.acmeDiscoveryUrl
, logsDir: args.logsDir , logsDir: args.logsDir
}; };
@ -156,7 +162,6 @@ function getCertificateAsync(account, args, defaults, handlers) {
} }
args.domainPrivateKeyPem = domainKey.privateKeyPem; args.domainPrivateKeyPem = domainKey.privateKeyPem;
args.account = account;
//args.registration = domainKey; //args.registration = domainKey;
return LeCore.getCertificateAsync({ return LeCore.getCertificateAsync({
@ -321,8 +326,8 @@ module.exports.create = function (defaults, handlers) {
console.log('[LE DEBUG] reg domains', args.domains); console.log('[LE DEBUG] reg domains', args.domains);
} }
return getOrCreateAcmeAccount(copy, defaults, handlers).then(function (account) { return getOrCreateAcmeAccount(copy, defaults, handlers).then(function (account) {
console.log('AAAAAAAAAACCCCCCCCCCCCCCCCOOOOOOOOOOOOOOUUUUUUUUUUUUUUUNNNNNNNNNNNNNNNNTTTTTTTTTTTT'); console.log("account", account);
console.log(account); args.account = account;
return getOrCreateDomainCertificate(account, copy, defaults, handlers); return getOrCreateDomainCertificate(account, copy, defaults, handlers);
}); });
} }