[BREAKING CHANGE] add _. for TXT
Just realized I can't put TXT on CNAME :/
This commit is contained in:
parent
7661a46132
commit
6b2a6e8186
4 changed files with 23 additions and 11 deletions
|
|
@ -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) {
|
||||
try {
|
||||
if (req.url.startsWith(acme_prefix)) {
|
||||
if (client.challengeCallbacks) {
|
||||
if (client.challengeCallbacks[req.headers.host]) {
|
||||
res.writeHead(200, {
|
||||
// This is important :)
|
||||
'content-type': 'application/octet-stream'
|
||||
});
|
||||
res.write(client.challengeCallbacks());
|
||||
res.write(client.challengeCallbacks[req.headers.host]());
|
||||
} else {
|
||||
res.writeHead(404)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,16 @@ function getCertCachePath(host) {
|
|||
return path.join(certsDir, hash.substr(0, 2), hash.substr(2), host);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} host
|
||||
*/
|
||||
async function findMaintainerEmail(host) {
|
||||
return await findTxtRecord(host, record_email_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} host
|
||||
*/
|
||||
async function buildCache(host) {
|
||||
const dir = getCertCachePath(host);
|
||||
const keyP = path.join(dir, 'privateKey.pem');
|
||||
|
|
@ -64,6 +70,9 @@ async function buildCache(host) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} servername
|
||||
*/
|
||||
async function getKeyCert(servername) {
|
||||
let cache = resolveCache[servername];
|
||||
await ensureDir(certsDir);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@ async function ensureDir(dir) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} host
|
||||
* @param {string} prefix
|
||||
*/
|
||||
async function findTxtRecord(host, prefix, required = true) {
|
||||
const resolve = await axios(`https://dns.google/resolve?name=${encodeURIComponent(host)}&type=TXT`);
|
||||
const resolve = await axios(`https://dns.google/resolve?name=_.${encodeURIComponent(host)}&type=TXT`);
|
||||
if (resolve.data.Answer) {
|
||||
for (const head of resolve.data.Answer) {
|
||||
if (!head.data.startsWith(prefix))
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue