fix challengeCallbacks
This commit is contained in:
parent
e91c4a9e9c
commit
e6b3ef7d52
2 changed files with 6 additions and 5 deletions
|
|
@ -40,7 +40,7 @@ class Client {
|
||||||
/** @type {import('crypto').KeyObject} */
|
/** @type {import('crypto').KeyObject} */
|
||||||
this.accountPublicKey = null
|
this.accountPublicKey = null
|
||||||
this.directoryUrl = directoryUrl
|
this.directoryUrl = directoryUrl
|
||||||
this.challengeCallbacks = {}
|
this.challengeCallbacks = null
|
||||||
this.hasDirectory = false
|
this.hasDirectory = false
|
||||||
this.myAccountUrl = ''
|
this.myAccountUrl = ''
|
||||||
this.newAccountUrl = ''
|
this.newAccountUrl = ''
|
||||||
|
|
@ -438,13 +438,14 @@ class Client {
|
||||||
reject(new Error('Timed out waiting for server request'))
|
reject(new Error('Timed out waiting for server request'))
|
||||||
}, 10e3);
|
}, 10e3);
|
||||||
let hasResolved = false;
|
let hasResolved = false;
|
||||||
this.challengeCallbacks[domain] = function () {
|
this.challengeCallbacks = () => {
|
||||||
if (!hasResolved)
|
if (!hasResolved)
|
||||||
setTimeout(resolve, 100);
|
setTimeout(resolve, 100);
|
||||||
else
|
else
|
||||||
return challenge.token + '.' + this.thumbprint;
|
return challenge.token + '.' + this.thumbprint;
|
||||||
hasResolved = true;
|
hasResolved = true;
|
||||||
clearTimeout(time);
|
clearTimeout(time);
|
||||||
|
this.challengeCallbacks = null;
|
||||||
return challenge.token + '.' + this.thumbprint;
|
return challenge.token + '.' + this.thumbprint;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ const acme_prefix = '/.well-known/acme-challenge/';
|
||||||
const listener = async function (/** @type {import('http').IncomingMessage} */ req, /** @type {import('http').ServerResponse} */ res) {
|
const listener = async function (/** @type {import('http').IncomingMessage} */ req, /** @type {import('http').ServerResponse} */ res) {
|
||||||
try {
|
try {
|
||||||
if (req.url.startsWith(acme_prefix)) {
|
if (req.url.startsWith(acme_prefix)) {
|
||||||
if (client.challengeCallbacks[req.headers.host]) {
|
if (client.challengeCallbacks) {
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
// This is important :)
|
// This is important :)
|
||||||
'content-type': 'application/octet-stream'
|
'content-type': 'application/octet-stream'
|
||||||
});
|
});
|
||||||
res.write(client.challengeCallbacks[req.headers.host]());
|
res.write(client.challengeCallbacks());
|
||||||
} else {
|
} else {
|
||||||
res.writeHead(404)
|
res.writeHead(404)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue