---
title: "CMSDecoderCopyAllCerts(_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/cmsdecodercopyallcerts(_:_:)"
---

# CMSDecoderCopyAllCerts(_:_:)

Obtains an array of all of the certificates in a message.

## Declaration

```swift
func CMSDecoderCopyAllCerts(_ cmsDecoder: CMSDecoder, _ certsOut: UnsafeMutablePointer<CFArray?>) -> OSStatus
```

## Parameters

- `cmsDecoder`: The CMSDecoder reference returned by the CMSDecoderCreate function.
- `certsOut`: On return, points to an array of SecCertificateRef objects. Returns NULL if the message does not contain any certificates (the message was encrypted but not signed); this is not considered an error. You must use the CFRelease function to free this reference when you are finished using it.

## Return Value

Return Value A result code. See Security Framework Result Codes.

## Discussion

Discussion A CMS message can contain arbitrary sets of certificates other than or in addition to those indicating the identity of signers. You can use this function to retrieve such certificates from a message. If the message was signed, it contains signer certificates. You can use the CMSDecoderGetNumSigners(_:_:) and CMSDecoderCopySignerCert(_:_:_:) functions to retrieve the certificates for a specific signer. You cannot call this function until after you have called the CMSDecoderFinalizeMessage(_:) function.

## See Also

### Related Documentation

- [CMSDecoderCopySignerCert(_:_:_:)](security/cmsdecodercopysignercert(_:_:_:).md)
- [CMSEncoderAddSupportingCerts(_:_:)](security/cmsencoderaddsupportingcerts(_:_:).md)
- [CMSDecoderGetNumSigners(_:_:)](security/cmsdecodergetnumsigners(_:_:).md)
- [CMSDecoderCreate(_:)](security/cmsdecodercreate(_:).md)
- [CMSDecoderFinalizeMessage(_:)](security/cmsdecoderfinalizemessage(_:).md)
