@@ -389,6 +389,56 @@ func (c *Client) GetCertificateContext(gca *GetCertificateContextArgs) (*GetCert
389389 return & jsonResp , err
390390}
391391
392+ func (c * Client ) ListCertificates (q map [string ]string ) ([]GetCertificateResponse , error ) {
393+ // Set Keyfactor-specific headers
394+ headers := & apiHeaders {
395+ Headers : []StringTuple {
396+ {"x-keyfactor-api-version" , "1" },
397+ {"x-keyfactor-requested-with" , "APIClient" },
398+ },
399+ }
400+
401+ // Construct URL query for /Certificates/{ID} requests
402+ query := apiQuery {
403+ Query : []StringTuple {},
404+ }
405+ query .Query = append (query .Query , StringTuple {
406+ "includeLocations" , "true" ,
407+ })
408+ searchCollection , ok := q ["collection" ]
409+ if ok {
410+ query .Query = append (query .Query , StringTuple {
411+ "collectionId" , searchCollection ,
412+ })
413+ }
414+ subjectName , ok := q ["subject" ]
415+ if ok {
416+ query .Query = append (query .Query , StringTuple {
417+ "pq.queryString" , fmt .Sprintf (`IssuedCN -eq "%s"` , subjectName ),
418+ })
419+ }
420+
421+ keyfactorAPIStruct := & request {
422+ Method : "GET" ,
423+ Endpoint : "Certificates" ,
424+ Headers : headers ,
425+ Query : & query ,
426+ Payload : nil ,
427+ }
428+
429+ resp , err := c .sendRequest (keyfactorAPIStruct )
430+ if err != nil {
431+ return nil , err
432+ }
433+
434+ var jsonResp []GetCertificateResponse
435+ err = json .NewDecoder (resp .Body ).Decode (& jsonResp )
436+ if err != nil {
437+ return nil , err
438+ }
439+ return jsonResp , err
440+ }
441+
392442// RecoverCertificate takes arguments for RecoverCertArgs to facilitate a call to Keyfactor
393443// that recovers a certificate and associated private key (if retained) in the specified format.
394444// The download certificate endpoint requires one of the following to retrieve a cert:
0 commit comments