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

Quiet OCSP warnings if the cert has a short lifetime #320

Merged
merged 4 commits into from
Nov 9, 2024

Conversation

francislavoie
Copy link
Member

In Caddy, we often get warnings like these when using internally issued certs:

{"level":"warn","ts":1731027618.3063543,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [localhost]: no OCSP server specified in certificate","identifiers":["localhost"]}

These generally have a very short lifetime and for that reason warning about them not having OCSP configured is just noise, because OCSP on short certs isn't too useful.

I added a Lifetime() method to help here, I used expiresAt for the "1s resolution of ASN.1 UTCTime/GeneralizedTime", hope that's correct.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, overall!

One thought I had: might it be a good idea to only stifle the warnings for the specific message of missing OCSP information (in short-lived certs)?

Because, if for some reason a short-lived cert had OCSP, you'd probably still want to know it. But I think specifically what we want to do is make it completely silent/OK if a short-lived cert specifically doesn't support OCSP. But if there was some sort of other error, like a network issue, we'd want to know it.

What do you think? The logic of calling Lifetime() would probably move into stapleOCSP and if the lifetime was short, we'd just set the err to nil and return (a no-op).

@francislavoie
Copy link
Member Author

How's this?

@francislavoie francislavoie requested a review from mholt November 8, 2024 19:38
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! That's it! Almost, I think 😄

ocsp.go Outdated Show resolved Hide resolved
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
mholt
mholt previously approved these changes Nov 8, 2024
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ 🌟 ⭐

@mholt
Copy link
Member

mholt commented Nov 8, 2024

Oh, lol, whodathunkit, we have a test for this: ocsp_test.go:151: expected error "no OCSP stapling for [ocsp test certificate]: no URL to issuing certificate" but got %!q(<nil>)

@francislavoie
Copy link
Member Author

Oh I guess this broke a test lmao

@mholt mholt merged commit 3fcd710 into caddyserver:master Nov 9, 2024
6 checks passed
@mholt
Copy link
Member

mholt commented Nov 9, 2024

Thanks a bunch!

@francislavoie francislavoie deleted the quiet-ocsp branch November 9, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants