---
title: "SecTrustGetCertificateAtIndex(_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/sectrustgetcertificateatindex(_:_:)"
---

# SecTrustGetCertificateAtIndex(_:_:)

Returns a specific certificate from the certificate chain used to evaluate trust.

## Declaration

```swift
func SecTrustGetCertificateAtIndex(_ trust: SecTrust, _ ix: CFIndex) -> SecCertificate?
```

## Parameters

- `trust`: The trust management object for the certificate that has been evaluated. Use the doc://com.apple.security/documentation/Security/SecTrustCreateWithCertificates(_:_:_:) function to create a trust management object and the doc://com.apple.security/documentation/Security/SecTrustEvaluateWithError(_:_:) function to evaluate the certificate chain.
- `ix`: The index number of the requested certificate. Index numbers start at 0 for the leaf certificate and end at the anchor (or the last certificate if no anchor was found). Use the doc://com.apple.security/documentation/Security/SecTrustGetCertificateCount(_:) function to get the total number of certificates in the chain.

## Return Value

Return Value A certificate object for the requested certificate.

## Discussion

Discussion Call the SecTrustEvaluateWithError(_:_:) function before calling this function.
