make polling faster, enable status updates
This commit is contained in:
parent
67294ae3eb
commit
21d01a326c
|
@ -249,6 +249,12 @@
|
||||||
<!-- Step 4 Process Challanges -->
|
<!-- Step 4 Process Challanges -->
|
||||||
<form class="js-acme-form js-acme-form-poll">
|
<form class="js-acme-form js-acme-form-poll">
|
||||||
Verifying Domains... (give us 5 seconds or so...)
|
Verifying Domains... (give us 5 seconds or so...)
|
||||||
|
<div class="js-challenge-responses" hidden>
|
||||||
|
Checking
|
||||||
|
<span class="js-challenge-response-altname"> </span>
|
||||||
|
using <span class="js-challenge-response-type"> </span>
|
||||||
|
: <span class="js-challenge-response-status"> </span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<table class="js-acme-table-verifying">
|
<table class="js-acme-table-verifying">
|
||||||
|
|
|
@ -2119,7 +2119,7 @@ ACME._untame = function (name, wild) {
|
||||||
|
|
||||||
// https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.5.1
|
// https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.5.1
|
||||||
ACME._postChallenge = function (me, options, auth) {
|
ACME._postChallenge = function (me, options, auth) {
|
||||||
var RETRY_INTERVAL = me.retryInterval || 1000;
|
var RETRY_INTERVAL = me.retryInterval || 5000;
|
||||||
var DEAUTH_INTERVAL = me.deauthWait || 10 * 1000;
|
var DEAUTH_INTERVAL = me.deauthWait || 10 * 1000;
|
||||||
var MAX_POLL = me.retryPoll || 8;
|
var MAX_POLL = me.retryPoll || 8;
|
||||||
var MAX_PEND = me.retryPending || 4;
|
var MAX_PEND = me.retryPending || 4;
|
||||||
|
@ -2161,9 +2161,11 @@ ACME._postChallenge = function (me, options, auth) {
|
||||||
|
|
||||||
function pollStatus() {
|
function pollStatus() {
|
||||||
if (count >= MAX_POLL) {
|
if (count >= MAX_POLL) {
|
||||||
return Promise.reject(new Error(
|
var err = new Error(
|
||||||
"[acme-v2] stuck in bad pending/processing state for '" + altname + "'"
|
"[acme-v2] stuck in bad pending/processing state for '" + altname + "'"
|
||||||
));
|
);
|
||||||
|
err.detail = "Too many attempts to validate challenge.";
|
||||||
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -2175,7 +2177,21 @@ ACME._postChallenge = function (me, options, auth) {
|
||||||
, url: auth.url
|
, url: auth.url
|
||||||
, protected: { kid: options._kid }
|
, protected: { kid: options._kid }
|
||||||
, payload: Enc.binToBuf('')
|
, payload: Enc.binToBuf('')
|
||||||
}).then(function (resp) {
|
}).then(checkResult).catch(transformError);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkResult(resp) {
|
||||||
|
if (options.onChallengeStatus) {
|
||||||
|
try {
|
||||||
|
options.onChallengeStatus({
|
||||||
|
altname: altname, type: auth.type, status: resp.body.status, wildcard: auth.wildcard
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
console.warn('options.onChallengeStatus Error:');
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ('processing' === resp.body.status) {
|
if ('processing' === resp.body.status) {
|
||||||
//#console.debug('poll: again');
|
//#console.debug('poll: again');
|
||||||
return ACME._wait(RETRY_INTERVAL).then(pollStatus);
|
return ACME._wait(RETRY_INTERVAL).then(pollStatus);
|
||||||
|
@ -2187,7 +2203,7 @@ ACME._postChallenge = function (me, options, auth) {
|
||||||
return ACME._wait(RETRY_INTERVAL).then(deactivate).then(respondToChallenge);
|
return ACME._wait(RETRY_INTERVAL).then(deactivate).then(respondToChallenge);
|
||||||
}
|
}
|
||||||
//#console.debug('poll: again');
|
//#console.debug('poll: again');
|
||||||
return ACME._wait(RETRY_INTERVAL).then(respondToChallenge);
|
return ACME._wait(RETRY_INTERVAL).then(pollStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('valid' === resp.body.status) {
|
if ('valid' === resp.body.status) {
|
||||||
|
@ -2204,7 +2220,9 @@ ACME._postChallenge = function (me, options, auth) {
|
||||||
err.code = code;
|
err.code = code;
|
||||||
|
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
}).catch(function (e) {
|
}
|
||||||
|
|
||||||
|
function transformError(e) {
|
||||||
var err = e;
|
var err = e;
|
||||||
if (err.urn) {
|
if (err.urn) {
|
||||||
err = new Error("[acme-v2] " + auth.altname + " status:" + e.status + " " + e.detail);
|
err = new Error("[acme-v2] " + auth.altname + " status:" + e.status + " " + e.detail);
|
||||||
|
@ -2215,7 +2233,6 @@ ACME._postChallenge = function (me, options, auth) {
|
||||||
}
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function respondToChallenge() {
|
function respondToChallenge() {
|
||||||
|
@ -2226,11 +2243,7 @@ ACME._postChallenge = function (me, options, auth) {
|
||||||
, url: auth.url
|
, url: auth.url
|
||||||
, protected: { kid: options._kid }
|
, protected: { kid: options._kid }
|
||||||
, payload: Enc.binToBuf(JSON.stringify({}))
|
, payload: Enc.binToBuf(JSON.stringify({}))
|
||||||
}).then(function (/*#resp*/) {
|
}).then(checkResult).catch(transformError);
|
||||||
//#console.debug('respond to challenge: resp.body:');
|
|
||||||
//#console.debug(resp.body);
|
|
||||||
return ACME._wait(RETRY_INTERVAL).then(pollStatus);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return respondToChallenge();
|
return respondToChallenge();
|
||||||
|
|
|
@ -404,6 +404,12 @@
|
||||||
, domainKeypair: { privateKeyJwk: serverJwk }
|
, domainKeypair: { privateKeyJwk: serverJwk }
|
||||||
, challengePriority: challengePriority
|
, challengePriority: challengePriority
|
||||||
, challenges: false
|
, challenges: false
|
||||||
|
, onChallengeStatus: function (details) {
|
||||||
|
$qs('.js-challenge-responses').hidden = false;
|
||||||
|
$qs('.js-challenge-response-type').innerText = details.type;
|
||||||
|
$qs('.js-challenge-response-status').innerText = details.status;
|
||||||
|
$qs('.js-challenge-response-altname').innerText = details.altname;
|
||||||
|
}
|
||||||
}).then(function (certs) {
|
}).then(function (certs) {
|
||||||
return Keypairs.export({ jwk: serverJwk }).then(function (keyPem) {
|
return Keypairs.export({ jwk: serverJwk }).then(function (keyPem) {
|
||||||
console.info('WINNING!');
|
console.info('WINNING!');
|
||||||
|
|
Loading…
Reference in New Issue