@@ -168,13 +168,15 @@ func (c *Client) DownloadCertificate(certId int, thumbprint string, serialNumber
168168 }
169169
170170 //todo: review this as it seems to be returning the wrong cert
171- leaf := certs .Certificates [1 ]
172171
172+ var leaf * x509.Certificate
173173 if len (certs .Certificates ) > 1 {
174+ //leaf is last cert in chain
175+ leaf = certs .Certificates [len (certs .Certificates )- 1 ]
174176 return leaf , certs .Certificates , nil
175177 }
176178
177- return leaf , nil , nil
179+ return certs . Certificates [ 0 ] , nil , nil
178180}
179181
180182// EnrollCSR takes arguments for EnrollCSRFctArgs to enroll a passed Certificate Signing
@@ -335,7 +337,7 @@ func (c *Client) GetCertificateContext(gca *GetCertificateContextArgs) (*GetCert
335337 query := apiQuery {
336338 Query : []StringTuple {},
337339 }
338- if gca .IncludeLocations != nil || gca .CollectionId != nil || gca .IncludeMetadata != nil {
340+ if gca .IncludeLocations != nil || gca .CollectionId != nil || gca .IncludeMetadata != nil || gca . IncludeHasPrivateKey != nil {
339341 if gca .IncludeLocations != nil {
340342 query .Query = append (query .Query , StringTuple {
341343 "includeLocations" , strconv .FormatBool (* gca .IncludeLocations ),
@@ -351,6 +353,11 @@ func (c *Client) GetCertificateContext(gca *GetCertificateContextArgs) (*GetCert
351353 "collectionId" , fmt .Sprintf ("%d" , * gca .CollectionId ),
352354 })
353355 }
356+ if gca .IncludeHasPrivateKey != nil {
357+ query .Query = append (query .Query , StringTuple {
358+ "includeHasPrivateKey" , strconv .FormatBool (* gca .IncludeHasPrivateKey ),
359+ })
360+ }
354361 }
355362
356363 var endpoint string
0 commit comments