Compare commits

..

3 Commits

Author SHA1 Message Date
AJ ONeal ba71e12ff2 v1.0.6 2018-05-09 23:49:19 -06:00
AJ ONeal 3e23ea5f8d better error handling 2018-05-09 23:48:52 -06:00
AJ ONeal bfc50ac9d2 better error handling 2018-05-09 23:46:43 -06:00
2 changed files with 40 additions and 10 deletions

48
node.js
View File

@ -434,15 +434,13 @@ ACME._finalizeOrder = function (me, options, validatedDomains) {
, headers: { 'Content-Type': 'application/jose+json' } , headers: { 'Content-Type': 'application/jose+json' }
, json: jws , json: jws
}).then(function (resp) { }).then(function (resp) {
// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.1.3
// Possible values are: "pending" => ("invalid" || "ready") => "processing" => "valid"
me._nonce = resp.toJSON().headers['replay-nonce']; me._nonce = resp.toJSON().headers['replay-nonce'];
if (me.debug) console.debug('order finalized: resp.body:'); if (me.debug) console.debug('order finalized: resp.body:');
if (me.debug) console.debug(resp.body); if (me.debug) console.debug(resp.body);
if ('processing' === resp.body.status) {
return ACME._wait().then(pollCert);
}
if ('valid' === resp.body.status) { if ('valid' === resp.body.status) {
me._expires = resp.body.expires; me._expires = resp.body.expires;
me._certificate = resp.body.certificate; me._certificate = resp.body.certificate;
@ -450,13 +448,45 @@ ACME._finalizeOrder = function (me, options, validatedDomains) {
return resp.body; return resp.body;
} }
if ('invalid' === resp.body.status) { if ('processing' === resp.body.status) {
console.error('cannot finalize: badness'); return ACME._wait().then(pollCert);
return;
} }
console.error('(x) cannot finalize: badness'); if (me.debug) console.debug("Error: bad status:\n" + JSON.stringify(resp.body, null, 2));
return;
if ('pending' === resp.body.status) {
return Promise.reject(new Error(
"Did not finalize order: status 'pending'."
+ " Best guess: You have not accepted at least one challenge for each domain." + "\n\n"
+ JSON.stringify(resp.body, null, 2)
));
}
if ('invalid' === resp.body.status) {
return Promise.reject(new Error(
"Did not finalize order: status 'invalid'."
+ " Best guess: One or more of the domain challenges could not be verified"
+ " (or the order was canceled)." + "\n\n"
+ JSON.stringify(resp.body, null, 2)
));
}
if ('ready' === resp.body.status) {
return Promise.reject(new Error(
"Did not finalize order: status 'ready'."
+ " Hmmm... this state shouldn't be possible here. That was the last state."
+ " This one should at least be 'processing'." + "\n\n"
+ JSON.stringify(resp.body, null, 2) + "\n\n"
+ "Please open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js"
));
}
return Promise.reject(new Error(
"Didn't finalize order: Unhandled status '" + resp.body.status + "'."
+ " This is not one of the known statuses...\n\n"
+ JSON.stringify(resp.body, null, 2) + "\n\n"
+ "Please open an issue at https://git.coolaj86.com/coolaj86/acme-v2.js"
));
}); });
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "acme-v2", "name": "acme-v2",
"version": "1.0.5", "version": "1.0.6",
"description": "Free SSL. A framework for building Let's Encrypt v2 clients, and other ACME v2 (draft 11) clients. Successor to le-acme-core.js", "description": "Free SSL. A framework for building Let's Encrypt v2 clients, and other ACME v2 (draft 11) clients. Successor to le-acme-core.js",
"homepage": "https://git.coolaj86.com/coolaj86/acme-v2.js", "homepage": "https://git.coolaj86.com/coolaj86/acme-v2.js",
"main": "node.js", "main": "node.js",