-
Notifications
You must be signed in to change notification settings - Fork 321
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
Check if TLS certificate and key file have been modified #345
Check if TLS certificate and key file have been modified #345
Conversation
4419fa0
to
546ae0d
Compare
I think we should only store the cert, you can not change the key without changing the cert. |
The issue with that would be if someone were to change only the key, yes, the TLS configuration would be invalid, but instead of getting (what I think would be) a |
de05404
to
102c12a
Compare
config/http_config.go
Outdated
} | ||
h1 := sha256.Sum256(b1) | ||
|
||
b2, b3, err := readCertAndKey(t.certFile, t.keyFile) |
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.
Where do we deal with unset certFile and t.keyFile?
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.
Could you please elaborate on what you mean by unset?
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.
I mean empty strings
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 point. A round tripper just isn't created if the CAFile
is unset, but we can't do the same with the certFile
and keyFile
.
Lines 452 to 455 in 102c12a
if len(cfg.TLSConfig.CAFile) == 0 { | |
// No need for a RoundTripper that reloads the CA file automatically. | |
return newRT(tlsConfig) | |
} |
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.
Should be fixed.
We are also hitting this problem, anything we can help with to move the PR forward? |
Apologies, I just need to find time to work on this. |
@LeviHarrison do you want me to pick up the work? This bug is becoming a significant issue for us right now. |
Yes, I think you can review&rebase |
e06f022
to
9294f56
Compare
Rebased on top of main, I didn't change anything to the PR except for resolving the conflicts. Thanks a lot @LeviHarrison! |
Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
This reverts commit c63387b. Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Signed-off-by: Simon Pasquier <[email protected]>
9294f56
to
d3fa312
Compare
@roidelapluie PTAL |
@roidelapluie friendly ping :) |
When the TLS certificate (used by Prometheus to authenticate to the scraped targets) gets rotated, Prometheus doesn't pick up the new certificate until the connection to the target is re-established. Because Prometheus uses keep-alive HTTP connections, the consequence is that the scrapes start failing after about 1 day and the TargetDown alert fires. There's an upstream pull request [1] to address the issue but it isn't merged yet. This commit pulls the changes from [1] into our downstream fork by adding a replace directive to go.mod for the github.com/prometheus/common. The replacement code is under patches/github.com/prometheus/common which is the same version as upstream (v0.37.0) + the upstream PR applied on top of it. As soon as upstream Prometheus depends on a version of github.com/prometheus/common that fixes the issue, the replace directive in go.mod and the code under the patches/ directory can be removed. [1] prometheus/common#345 Signed-off-by: Simon Pasquier <[email protected]>
When the TLS certificate (used by Prometheus to authenticate to the scraped targets) gets rotated, Prometheus doesn't pick up the new certificate until the connection to the target is re-established. Because Prometheus uses keep-alive HTTP connections, the consequence is that the scrapes start failing after about 1 day and the TargetDown alert fires. There's an upstream pull request [1] to address the issue but it isn't merged yet. This commit pulls the changes from [1] into our downstream fork by adding a replace directive to go.mod for the github.com/prometheus/common. The replacement code is under patches/github.com/prometheus/common which is the same version as upstream (v0.37.0) + the upstream PR applied on top of it. As soon as upstream Prometheus depends on a version of github.com/prometheus/common that fixes the issue, the replace directive in go.mod and the code under the patches/ directory can be removed. [1] prometheus/common#345 Signed-off-by: Simon Pasquier <[email protected]>
When the TLS certificate (used by Prometheus to authenticate to the scraped targets) gets rotated, Prometheus doesn't pick up the new certificate until the connection to the target is re-established. Because Prometheus uses keep-alive HTTP connections, the consequence is that the scrapes start failing after about 1 day and the TargetDown alert fires. There's an upstream pull request [1] to address the issue but it isn't merged yet. This commit pulls the changes from [1] into our downstream fork by adding a replace directive to go.mod for the github.com/prometheus/common. The replacement code is under patches/github.com/prometheus/common which is the same version as upstream (v0.37.0) + the upstream PR applied on top of it. As soon as upstream Prometheus depends on a version of github.com/prometheus/common that fixes the issue, the replace directive in go.mod and the code under the patches/ directory can be removed. [1] prometheus/common#345 Signed-off-by: Simon Pasquier <[email protected]>
When the TLS certificate (used by Prometheus to authenticate to the scraped targets) gets rotated, Prometheus doesn't pick up the new certificate until the connection to the target is re-established. Because Prometheus uses keep-alive HTTP connections, the consequence is that the scrapes start failing after about 1 day and the TargetDown alert fires. There's an upstream pull request [1] to address the issue but it isn't merged yet. This commit pulls the changes from [1] into our downstream fork by adding a replace directive to go.mod for the github.com/prometheus/common. The replacement code is under patches/github.com/prometheus/common which is the same version as upstream (v0.37.0) + the upstream PR applied on top of it. As soon as upstream Prometheus depends on a version of github.com/prometheus/common that fixes the issue, the replace directive in go.mod and the code under the patches/ directory can be removed. [1] prometheus/common#345 Signed-off-by: Simon Pasquier <[email protected]>
Thanks! |
When the TLS certificate (used by Prometheus to authenticate to the scraped targets) gets rotated, Prometheus doesn't pick up the new certificate until the connection to the target is re-established. Because Prometheus uses keep-alive HTTP connections, the consequence is that the scrapes start failing after about 1 day and the TargetDown alert fires. There's an upstream pull request [1] to address the issue but it isn't merged yet. This commit pulls the changes from [1] into our downstream fork by adding a replace directive to go.mod for the github.com/prometheus/common. The replacement code is under patches/github.com/prometheus/common which is the same version as upstream (v0.37.0) + the upstream PR applied on top of it. As soon as upstream Prometheus depends on a version of github.com/prometheus/common that fixes the issue, the replace directive in go.mod and the code under the patches/ directory can be removed. [1] prometheus/common#345 Signed-off-by: Simon Pasquier <[email protected]>
- Check if TLS certificate and key file have been modified prometheus/common#345 - Add the ability to specify the maximum acceptable TLS version prometheus/common#414 Signed-off-by: Julien Pivotto <[email protected]>
) * Check hash of cert and key file Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
) * Check hash of cert and key file Signed-off-by: Levi Harrison <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
This PR adds the capability to check the hashes of the client certificate and key files to see if they've been modified, as is already done with the CA file.
Fixes prometheus/prometheus#9512