-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Heartbeat] Fix expiration of cert chains calculation #33231
Conversation
Fixes elastic#33215 This is a bit WIP in that I'm not certain this is the final logic we want. It appears the elastic agent libs override the default golang TLS implementation's verification and only set the cert chains attribute on the connection when strict validation is enabled, where the default is `full`. See https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-ssl.html for definition of the various validation options. I suspect we'd be best off making strict the default since this is what chrome does nowadays, requiring a SAN to be set, which is the only other distinction. To test this use the following config, which returns a too-early expiration date without this patch: ``` - type: http enabled: true id: wyportal name: WYPortal schedule: "@every 1m" ssl.verification_mode: strict urls: "https://portals.edu.wyoming.gov/" ``` You can try playing with the verification mode as well
Pinging @elastic/uptime (Team:Uptime) |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the strict
by default discussion, it would seem the actual config that drives chain behaviour is InsecureSkipVerify
, not verification_mode
itself. Could we add this as a default for all https monitors? It would still make possible to get the correct result with full
verification mode.
|
||
// If this chain expires sooner than a previously seen chain we don't | ||
// set any fields | ||
if chainNotAfter.Before(maxNotAfterFloor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxNotAfterFloor
is not updated in the loop, so all chains go through overriding each other. Is that expected? Shouldn't this be initialiazed to Edit: nvm, chain expiration can pre-date peer certificate expirationhostCert.NotAfter
if available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will fix
This pull request is now in conflicts. Could you fix it? 🙏
|
@emilioalvap this is now ready for review again, I spent probably a bit too much effort improving the logic and test cases in aa35bb0 , while I think it could be cleaned up further, given that this requires strict, I think it covers more than can probably be justified given the effort of digging up the right certs. |
Taking the PR off the board as the parent issue is on there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, reviewed test scenarios locally and it holds up. Still some linting to fix, though
@Mergifyio backport 8.5 |
✅ Backports have been created
|
* [Heartbeat] Fix expiration of cert chains calculation Fixes #33215 This is a bit WIP in that I'm not certain this is the final logic we want. It appears the elastic agent libs override the default golang TLS implementation's verification and only set the cert chains attribute on the connection when strict validation is enabled, where the default is `full`. See https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-ssl.html for definition of the various validation options. I suspect we'd be best off making strict the default since this is what chrome does nowadays, requiring a SAN to be set, which is the only other distinction. To test this use the following config, which returns a too-early expiration date without this patch: ``` - type: http enabled: true id: wyportal name: WYPortal schedule: "@every 1m" ssl.verification_mode: strict urls: "https://portals.edu.wyoming.gov/" ``` You can try playing with the verification mode as well * Cleanup work * Add changelog * Fix cert calculations * Fix lint (cherry picked from commit bd081b6)
@Mergifyio backport 7.17 |
* [Heartbeat] Fix expiration of cert chains calculation Fixes #33215 This is a bit WIP in that I'm not certain this is the final logic we want. It appears the elastic agent libs override the default golang TLS implementation's verification and only set the cert chains attribute on the connection when strict validation is enabled, where the default is `full`. See https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-ssl.html for definition of the various validation options. I suspect we'd be best off making strict the default since this is what chrome does nowadays, requiring a SAN to be set, which is the only other distinction. To test this use the following config, which returns a too-early expiration date without this patch: ``` - type: http enabled: true id: wyportal name: WYPortal schedule: "@every 1m" ssl.verification_mode: strict urls: "https://portals.edu.wyoming.gov/" ``` You can try playing with the verification mode as well * Cleanup work * Add changelog * Fix cert calculations * Fix lint (cherry picked from commit bd081b6) # Conflicts: # heartbeat/hbtest/hbtestutil.go # heartbeat/monitors/active/dialchain/tlsmeta/tlsmeta.go # heartbeat/monitors/active/dialchain/tlsmeta/tlsmeta_test.go # heartbeat/monitors/active/http/task.go # heartbeat/monitors/active/tcp/tcp.go
✅ Backports have been created
|
* [Heartbeat] Fix expiration of cert chains calculation Fixes #33215 This is a bit WIP in that I'm not certain this is the final logic we want. It appears the elastic agent libs override the default golang TLS implementation's verification and only set the cert chains attribute on the connection when strict validation is enabled, where the default is `full`. See https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-ssl.html for definition of the various validation options. I suspect we'd be best off making strict the default since this is what chrome does nowadays, requiring a SAN to be set, which is the only other distinction. To test this use the following config, which returns a too-early expiration date without this patch: ``` - type: http enabled: true id: wyportal name: WYPortal schedule: "@every 1m" ssl.verification_mode: strict urls: "https://portals.edu.wyoming.gov/" ``` You can try playing with the verification mode as well * Cleanup work * Add changelog * Fix cert calculations * Fix lint (cherry picked from commit bd081b6) Co-authored-by: Andrew Cholakian <[email protected]>
* [Heartbeat] Fix expiration of cert chains calculation Fixes #33215 This is a bit WIP in that I'm not certain this is the final logic we want. It appears the elastic agent libs override the default golang TLS implementation's verification and only set the cert chains attribute on the connection when strict validation is enabled, where the default is `full`. See https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-ssl.html for definition of the various validation options. I suspect we'd be best off making strict the default since this is what chrome does nowadays, requiring a SAN to be set, which is the only other distinction. To test this use the following config, which returns a too-early expiration date without this patch: ``` - type: http enabled: true id: wyportal name: WYPortal schedule: "@every 1m" ssl.verification_mode: strict urls: "https://portals.edu.wyoming.gov/" ``` You can try playing with the verification mode as well * Cleanup work * Add changelog * Fix cert calculations * Fix lint
Fixes #33215
This is a bit WIP in that I'm not certain this is the final logic we want. It appears the elastic agent libs override the default golang TLS implementation's verification and only set the cert chains attribute on the connection when
strict
validation is enabled, where the default isfull
. See https://www.elastic.co/guide/en/beats/heartbeat/current/configuration-ssl.html for definition of the various validation options.I suspect we'd be best off making strict the default since this is what chrome does nowadays, requiring a SAN to be set, which is the only distinction between the checks of
strict
andfull
.To test this use the following config, which returns a too-early expiration date without this patch:
You can try playing with the verification mode as well
What does this PR do?
Why is it important?
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Use the above config and run and build with the following command to prune the output. Note this requires your heartbeat yaml to not have an
output
section set.