mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-09 15:06:59 +08:00
Merge branch '1.23.X' into 1.23.13-to-2.0.0
# Conflicts: # .github/workflows/auto-test.yml # package-lock.json # package.json # server/database.js # server/model/monitor.js # server/monitor-types/real-browser-monitor-type.js # server/util-server.js # test/cypress/unit/i18n.spec.js
This commit is contained in:
@@ -653,21 +653,27 @@ const parseCertificateInfo = function (info) {
|
||||
|
||||
/**
|
||||
* Check if certificate is valid
|
||||
* @param {object} res Response object from axios
|
||||
* @returns {object} Object containing certificate information
|
||||
* @throws No socket was found to check certificate for
|
||||
* @param {tls.TLSSocket} socket TLSSocket, which may or may not be connected
|
||||
* @returns {Object} Object containing certificate information
|
||||
*/
|
||||
exports.checkCertificate = function (res) {
|
||||
if (!res.request.res.socket) {
|
||||
throw new Error("No socket found");
|
||||
exports.checkCertificate = function (socket) {
|
||||
let certInfoStartTime = dayjs().valueOf();
|
||||
|
||||
// Return null if there is no socket
|
||||
if (socket === undefined || socket == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const info = res.request.res.socket.getPeerCertificate(true);
|
||||
const valid = res.request.res.socket.authorized || false;
|
||||
const info = socket.getPeerCertificate(true);
|
||||
const valid = socket.authorized || false;
|
||||
|
||||
log.debug("cert", "Parsing Certificate Info");
|
||||
const parsedInfo = parseCertificateInfo(info);
|
||||
|
||||
if (process.env.TIMELOGGER === "1") {
|
||||
log.debug("monitor", "Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms");
|
||||
}
|
||||
|
||||
return {
|
||||
valid: valid,
|
||||
certInfo: parsedInfo
|
||||
|
Reference in New Issue
Block a user