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({
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) {
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) {
return data[url];
})) {
console.warn("This Let's Encrypt / ACME server is missing urls that this client may need.");
console.warn(data);
}
ipc.acmeUrlsUpdatedAt = Date.now();
@ -56,7 +68,7 @@ function createAccount(args, handlers) {
return lef.registerNewAccountAsync({
email: args.email
, newReg: args.server
, newReg: args._acmeUrls.newReg
, debug: args.debug || handlers.debug
, agreeToTerms: function (tosUrl, agree) {
// 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.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;
}, function (err) {
if ("EENOENT" === err.code) {
@ -189,7 +201,7 @@ module.exports.create = function (defaults, handlers) {
if (accountId) {
return getAccount(accountId, args, handlers);
} else {
return createAccount(args);
return createAccount(args, handlers);
}
});
}).then(function (account) {

View File

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