@@ -31,6 +31,7 @@ const (
31
31
FROM certificate_and_identities cai
32
32
WHERE plainto_tsquery('certwatch', '%s') @@ identities(cai.CERTIFICATE)
33
33
AND cai.NAME_VALUE ILIKE ('%%' || '%s' || '%%')
34
+ %s --filter
34
35
LIMIT 10000
35
36
) sub
36
37
GROUP BY sub.CERTIFICATE
@@ -54,6 +55,9 @@ FROM ci
54
55
WHERE ci.ISSUER_CA_ID = ca.ID
55
56
ORDER BY le.ENTRY_TIMESTAMP DESC NULLS LAST
56
57
LIMIT %d`
58
+
59
+ excludeExpired = `AND coalesce(x509_notAfter(cai.CERTIFICATE), 'infinity'::timestamp) >= date_trunc('year', now() AT TIME ZONE 'UTC')
60
+ AND x509_notAfter(cai.CERTIFICATE) >= now() AT TIME ZONE 'UTC'`
57
61
)
58
62
59
63
type Repository struct {
@@ -69,8 +73,14 @@ func New() (*Repository, error) {
69
73
return & Repository {db }, nil
70
74
}
71
75
72
- func (r * Repository ) GetCertLogs (domain string , limit int ) (result.CertResult , error ) {
73
- stmt := fmt .Sprintf (statement , domain , domain , limit )
76
+ func (r * Repository ) GetCertLogs (domain string , expired bool , limit int ) (result.CertResult , error ) {
77
+ filter := ""
78
+
79
+ if expired {
80
+ filter = excludeExpired
81
+ }
82
+
83
+ stmt := fmt .Sprintf (statement , domain , domain , filter , limit )
74
84
75
85
rows , err := r .db .Query (stmt )
76
86
if err != nil {
0 commit comments