more working

This commit is contained in:
AJ ONeal 2015-12-15 13:11:19 +00:00
parent bdeb1357d4
commit c44935e7df
2 changed files with 19 additions and 7 deletions

View File

@ -22,14 +22,26 @@ function getAcmeUrls(args) {
return requestAsync({ return requestAsync({
url: args.server url: args.server
}).then(function (data) { }).then(function (resp) {
var data = resp.body;
if ('string' === typeof data) {
try {
data = JSON.parse(data);
} catch(e) {
return PromiseA.reject(e);
}
}
if (4 !== Object.keys(data).length) { if (4 !== Object.keys(data).length) {
console.warn("This Let's Encrypt / ACME server has been updated with urls that this client doesn't understand"); console.warn("This Let's Encrypt / ACME server has been updated with urls that this client doesn't understand");
console.warn(data);
} }
if (!knownUrls.every(function (url) { if (!knownUrls.every(function (url) {
return data[url]; return data[url];
})) { })) {
console.warn("This Let's Encrypt / ACME server is missing urls that this client may need."); console.warn("This Let's Encrypt / ACME server is missing urls that this client may need.");
console.warn(data);
} }
ipc.acmeUrlsUpdatedAt = Date.now(); ipc.acmeUrlsUpdatedAt = Date.now();
@ -56,7 +68,7 @@ function createAccount(args, handlers) {
return lef.registerNewAccountAsync({ return lef.registerNewAccountAsync({
email: args.email email: args.email
, newReg: args.server , newReg: args._acmeUrls.newReg
, debug: args.debug || handlers.debug , debug: args.debug || handlers.debug
, agreeToTerms: function (tosUrl, agree) { , agreeToTerms: function (tosUrl, agree) {
// args.email = email; // already there // args.email = email; // already there
@ -173,7 +185,7 @@ module.exports.create = function (defaults, handlers) {
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');
pyconf.readFileAsync(args.renewalDir).then(function (renewal) { return pyconf.readFileAsync(args.renewalDir).then(function (renewal) {
return renewal.account; return renewal.account;
}, function (err) { }, function (err) {
if ("EENOENT" === err.code) { if ("EENOENT" === err.code) {
@ -189,7 +201,7 @@ module.exports.create = function (defaults, handlers) {
if (accountId) { if (accountId) {
return getAccount(accountId, args, handlers); return getAccount(accountId, args, handlers);
} else { } else {
return createAccount(args); return createAccount(args, handlers);
} }
}); });
}).then(function (account) { }).then(function (account) {

View File

@ -27,8 +27,8 @@ function toAcmePrivateKey(privkeyPem) {
function generateRsaKeypair(bitlen, exp, cb) { function generateRsaKeypair(bitlen, exp, cb) {
var keypair = ursa.generatePrivateKey(bitlen /*|| 2048*/, exp /*65537*/); var keypair = ursa.generatePrivateKey(bitlen /*|| 2048*/, exp /*65537*/);
var pems = { var pems = {
publicKeyPem: keypair.toPublicPem() // ascii PEM: ----BEGIN... publicKeyPem: keypair.toPublicPem().toString('ascii') // ascii PEM: ----BEGIN...
, privateKeyPem: keypair.toPrivatePem() // ascii PEM: ----BEGIN... , privateKeyPem: keypair.toPrivatePem().toString('ascii') // ascii PEM: ----BEGIN...
}; };
// I would have chosen sha1 or sha2... but whatever // I would have chosen sha1 or sha2... but whatever
@ -67,7 +67,7 @@ function parseAccountPrivateKey(pkj, cb) {
cb(null, { cb(null, {
privateKeyPem: priv.toPrivatePem.toString('ascii') privateKeyPem: priv.toPrivatePem.toString('ascii')
, publicKeyPem: priv.toPrivatePem.toString('ascii') , publicKeyPem: priv.toPublicPem.toString('ascii')
}); });
} }