fix(certs): default to active certs when no search term

EJBCA's certificate/search REST endpoint rejects an empty criteria list
("Invalid criteria value, cannot be empty"), so GET /certs with no ?search
returned a 500. Default to a STATUS=CERT_ACTIVE criterion in that case so the
list endpoint returns active certificates. Search-by-query is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Claude (gsc-ops-api init)
2026-06-01 12:13:52 +02:00
parent 2de3fb0ead
commit 30268db4be

View File

@@ -38,6 +38,15 @@ func (s *CertificateService) ListCertificates(search string, limit int) ([]types
Value: search,
Operation: "LIKE",
})
} else {
// EJBCA rejects an empty criteria list ("Invalid criteria value,
// cannot be empty"). With no search term, default to listing active
// certificates so GET /certs returns a useful result instead of 500.
criteria = append(criteria, client.CertSearchCriterion{
Property: "STATUS",
Value: "CERT_ACTIVE",
Operation: "EQUAL",
})
}
certs, err := s.client.SearchCertificates(&client.CertSearchRequest{