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

Add new probe_ssl_latest_verified_chain_expiry metric #636

Merged

Conversation

itkq
Copy link
Contributor

@itkq itkq commented Jun 7, 2020

Resolves #340

Based on the discussion in the issue above, this metric will help determine
when the SSL/TLS certificate expiration error actually happens on clients
like a browser that attempts to verify certificates by building one or
more chains from peer certificates.

Resolves prometheus#340

Based on the discussion in the issue above, this metric will help determine
when the SSL/TLS certificate expiration error actually happens on clients
like a browser that attempts to verify certificates by building one or
more chains from peer certificates.

Signed-off-by: Takuya Kosugiyama <[email protected]>
@itkq itkq force-pushed the probe_ssl_latest_verified_chain_expiry branch from 4404f90 to a70527c Compare June 7, 2020 00:16
Copy link
Contributor

@brian-brazil brian-brazil left a comment

Choose a reason for hiding this comment

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

Thanks for sending this in. Can you also add a basic unittest?

prober/tls.go Outdated
@@ -28,6 +28,23 @@ func getEarliestCertExpiry(state *tls.ConnectionState) time.Time {
return earliest
}

func getLatestVerifiedChainExpiry(state *tls.ConnectionState) time.Time {
latestVerifiedChainExpiry := time.Time{}
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this output if there's no chains? You'll probably need insecure_skip_verify to test this.

prober/tcp.go Outdated
@@ -94,6 +94,10 @@ func ProbeTCP(ctx context.Context, target string, module config.Module, registry
Name: "probe_ssl_earliest_cert_expiry",
Help: "Returns earliest SSL cert expiry date",
})
probeSSLLatestVerifiedChainExpiry := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "probe_ssl_latest_verified_chain_expiry",
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a little of a mouthful, and naming conventions have matured since the previous one was named.

I'd go for something like probe_ssl_last_chain_expiry_timestamp_seconds.

@itkq
Copy link
Contributor Author

itkq commented Jun 8, 2020

Changed the name of the metric a bit and also added a unit test.

prober/tcp.go Outdated
probeTLSVersion.WithLabelValues(getTLSVersion(&state)).Set(1)

if lastChainExpiry, ok := getLastChainExpiry(&state); ok {
registry.MustRegister(probeSSLLastChainExpiryTimestampSeconds)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep this consistent with the other tls metric, both in terms of registration and what happens when there's no certs.

prober/tcp.go Outdated
Help: "Returns latest SSL verified chain expiry date",
probeSSLLastChainExpiryTimestampSeconds := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "probe_ssl_last_chain_expiry_timestamp_seconds",
Help: "Returns last SSL chain expiry in timestamp seconds",
Copy link
Contributor

Choose a reason for hiding this comment

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

in unixtime

Looks like the existing metric help could do with some consistency too.

// Prepare certificates to simulate a situation where
// the root certificate in the chain sent by the server
// expired but a verified certificate chain can be found
// because a new one has installed on the local machine.
Copy link
Contributor

Choose a reason for hiding this comment

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

"one" is ambiguous here. Root?

This also feels like we're testing Go's root handling rather than testing our own code. Having two chains where one is expired would seem like a better test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. I made a change to do that in d45159b

@itkq itkq force-pushed the probe_ssl_latest_verified_chain_expiry branch from fb1fcc7 to d45159b Compare June 10, 2020 02:17
@brian-brazil brian-brazil merged commit 725a683 into prometheus:master Jun 10, 2020
@brian-brazil
Copy link
Contributor

Thanks!

@itkq itkq deleted the probe_ssl_latest_verified_chain_expiry branch June 10, 2020 22:11
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.

Wrong probe_ssl_earliest_cert_expiry value for certificates with multiple trust chains
2 participants