categraf/inputs/http_response/tls.go

17 lines
338 B
Go
Raw Normal View History

2022-05-14 16:26:52 +08:00
package http_response
2022-04-20 15:35:39 +08:00
import (
"crypto/tls"
"time"
)
func getEarliestCertExpiry(state *tls.ConnectionState) time.Time {
earliest := time.Time{}
for _, cert := range state.PeerCertificates {
if (earliest.IsZero() || cert.NotAfter.Before(earliest)) && !cert.NotAfter.IsZero() {
earliest = cert.NotAfter
}
}
return earliest
}