Handle unnaceptable nonce values

This commit is contained in:
Valters Jansons 2019-07-29 12:38:56 +03:00
parent a060ecd130
commit fe96e94e06
No known key found for this signature in database
GPG Key ID: 4F021EB3A83CE748
1 changed files with 24 additions and 0 deletions

24
node.js
View File

@ -1001,6 +1001,18 @@ ACME._finalizeOrder = function(me, options, validatedDomains) {
); );
} }
// The documented ACME error code is "urn:ietf:params:acme:error:badNonce"
// however some servers historically have done their variations, so just check `:badnonce`.
// https://tools.ietf.org/html/rfc8555#section-6.5
if (resp.body.type.toLowerCase().endsWith(':badnonce')) {
if (me.debug) {
console.debug('[acme-v2] Nonce value unacceptable; retrying with a new nonce');
}
// `me._nonce` has been reset earlier in this function, so just call `poll` again.
return pollCert();
}
return Promise.reject( return Promise.reject(
new Error( new Error(
"Didn't finalize order: Unhandled status '" + "Didn't finalize order: Unhandled status '" +
@ -1176,6 +1188,18 @@ ACME._getCertificate = function(me, options) {
//if (me.debug) console.debug('[DEBUG] finalize:', me._finalize); return; //if (me.debug) console.debug('[DEBUG] finalize:', me._finalize); return;
if (!me._authorizations) { if (!me._authorizations) {
// The documented ACME error code is "urn:ietf:params:acme:error:badNonce"
// however some servers historically have done their variations, so just check `:badnonce`.
// https://tools.ietf.org/html/rfc8555#section-6.5
if (resp.body.type.toLowerCase().endsWith(':badnonce')) {
if (me.debug) {
console.debug('[acme-v2] Nonce value unacceptable; retrying with a new nonce');
}
// `me._nonce` has been reset earlier in this function, so just call `get` again.
return ACME._getCertificate(me, options);
}
return Promise.reject( return Promise.reject(
new Error( new Error(
"[acme-v2.js] authorizations were not fetched for '" + "[acme-v2.js] authorizations were not fetched for '" +