fix: add custom certificate validation to pixiv-got (#6830)
Fixes #6584
This commit is contained in:
parent
ecba021f17
commit
c8275d890d
|
|
@ -1,3 +1,4 @@
|
|||
const tls = require('tls');
|
||||
const ipRegex = require('ip-regex');
|
||||
const got = require('@/utils/got');
|
||||
const logger = require('@/utils/logger');
|
||||
|
|
@ -20,7 +21,7 @@ async function dohResolve(name, jsonDohEndpoint) {
|
|||
return response.data.Answer.map((item) => item.data);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(`Failed to resolve ${pixivConfig.bypassCdnHostname}`);
|
||||
logger.error(`Failed to resolve ${name}`);
|
||||
logger.debug(e);
|
||||
}
|
||||
return [];
|
||||
|
|
@ -46,11 +47,15 @@ const pixivGot = got.extend({
|
|||
}
|
||||
}
|
||||
if (hostname) {
|
||||
const actualHost = options.url.host;
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
host: options.url.host,
|
||||
host: actualHost,
|
||||
};
|
||||
options.url.hostname = hostname;
|
||||
options.checkServerIdentity = function (host, certificate) {
|
||||
return tls.checkServerIdentity(actualHost, certificate);
|
||||
};
|
||||
}
|
||||
},
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue