Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA check reports -635 days #3323

Closed
2 tasks done
yitsushi opened this issue Jun 27, 2023 · 12 comments · Fixed by #3874
Closed
2 tasks done

CA check reports -635 days #3323

yitsushi opened this issue Jun 27, 2023 · 12 comments · Fixed by #3874
Labels
bug Something isn't working question Further information is requested

Comments

@yitsushi
Copy link

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

Description

After I updated to 1.22.0 I got a lot of notifications about "expired" CA certificates. My certs are coming from Let's encrypt and they are Not After: Mon, 04 Jun 2035 11:04:38 GMT.

image
(matrix alert)

I have a few platforms to alert and I got spammed on all channels.

👟 Reproduction steps

I just update, nothing special.

👀 Expected behavior

I don't get notified about expired CA certificate if it's not expired.

😓 Actual Behavior

I got expired CA notification for every single https monitors.

🐻 Uptime-Kuma Version

1.22.0

💻 Operating System and Arch

Ubuntu 20.04

🌐 Browser

N/A

🐋 Docker Version

Docker 20.10.14 + Swarm

🟩 NodeJS Version

I'm using the official docker image

📝 Relevant log output

nothing
@yitsushi yitsushi added the bug Something isn't working label Jun 27, 2023
@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Jun 27, 2023

@helix26j
Copy link

helix26j commented Jun 27, 2023

But that CA is expired, so the server certificate would also reflect expired even though it was issued beyond the expiry date of the CA:
https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

This is an old issue, though the article suggests they could be cross-signed so if that is the case perhaps it has to do with the method used to verify it. I can't see the details of the CA nor the intermediates which would have signed this cert.

@louislam louislam added cannot-reproduce question Further information is requested and removed cannot-reproduce labels Jun 28, 2023
@louislam
Copy link
Owner

I think the message indeed is not handled correctly. It actually means that your CA cert has been expired for 635 days. You should update your CA cert.

You can click here to see the cert details.

image

@yitsushi
Copy link
Author

Indeed it's expired. When I checked this page I think I misread that part (or my eyes said "nope I'm not going to read that, the first 3 are correct".

image

@feld
Copy link

feld commented Jul 5, 2023

I'm getting this too on every HTTPS endpoint I am monitoring with the certificate expiration check enabled.

I don't see the point in monitoring the Root CA's expiration by default. That should probably be an advanced option and UptimeKuma really needs to better understand certificate chains / cross signing so these false positives don't happen.

edit: if you don't want UptimeKuma to bother checking expiration of the rest of the cert chain you can use this crude hack to stop it from checking

diff --git a/server/model/monitor.js b/server/model/monitor.js
index 2732a341..28503fe6 100644
--- a/server/model/monitor.js
+++ b/server/model/monitor.js
@@ -1287,7 +1287,7 @@ class Monitor extends BeanModel {
                             log.debug("monitor", `call sendCertNotificationByTargetDays for ${targetDays} deadline on certificate ${subjectCN}.`);
                             await this.sendCertNotificationByTargetDays(subjectCN, certInfo.certType, certInfo.daysRemaining, targetDays, notificationList);
                         }
-                        certInfo = certInfo.issuerCertificate;
+                        certInfo = null;
                     }
                 }
             }

@chakflying
Copy link
Collaborator

chakflying commented Jul 5, 2023

@skaempfe

It's evidently not a good idea to notify every cert in the chain for expiry. I don't see any other way to fix this then to check each cert against some "trusted roots", and stopping there.

@feld
Copy link

feld commented Jul 5, 2023

@skaempfe

I don't see any other way to fix this then to check each cert against some "trusted roots", and stopping there.

But testing if the certificate is valid is already being handled, right?

/**
 * Check if certificate is valid
 * @param {Object} res Response object from axios
 * @returns {Object} Object containing certificate information
 */
exports.checkCertificate = function (res) {
    if (!res.request.res.socket) {
        throw new Error("No socket found");
    }

    const info = res.request.res.socket.getPeerCertificate(true);
    const valid = res.request.res.socket.authorized || false;  👈 👈 👈 👈

    log.debug("cert", "Parsing Certificate Info");
    const parsedInfo = parseCertificateInfo(info);

    return {
        valid: valid, 👈 👈 👈 👈
        certInfo: parsedInfo
    };
};

if res.request.res.socket.authorized is false the certificate is not trusted, which should happen when the issuer or an intermediate is expired, or if it's from an untrusted root

@chakflying
Copy link
Collaborator

authorized returns whether the whole chain is trusted. It doesn't give any information about which certificate is valid or not.

@feld
Copy link

feld commented Jul 5, 2023

Correct, but that should be sufficient.

I've never seen an HTTPS monitoring tool try to validate the whole chain's expirations. Typically (IMO) you'll monitor that certificate directly with another mechanism otherwise you just end up with hundreds or thousands of redundant alert notifications when your private CA root is going to be expiring.

If e.g., LetsEncrypt's CA is expiring next week, notifying me is rather pointless. If we have to do the CA's job for them we're in a heap of trouble...

Anyway, just glad I found a workaround so I can continue experimenting with this software.

Thanks, all!

@gmta
Copy link

gmta commented Sep 6, 2023

Note that a TLS CA certificate expiry is only relevant if it's part of the trust chain. In this case, it's not, since there's another CA certificate beside it that has not yet expired.

See also: https://letsencrypt.org/certificates/

@foliovision
Copy link

We had to stop the SSL checking of Uptime Kuma as it was completely useless for these Letsencrypt certificates.

Would it be possible to simple ignore errors with the "DST Root CA X3" certificate that expires on 2021-09-30?

Seems like that would stop the false alarms for Letsencrypt without having it understand that modern browsers no longer need that certificate.

@chakflying
Copy link
Collaborator

Fixed by #3874.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants