<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/CMSDecoderCopyAllCerts(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@CMSDecoderCopyAllCerts"
  },
  "title" : "CMSDecoderCopyAllCerts(_:_:)"
}
-->

# CMSDecoderCopyAllCerts(_:_:)

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

```
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

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes).

## 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(_:_:)`](/documentation/Security/CMSDecoderGetNumSigners(_:_:)) and [`CMSDecoderCopySignerCert(_:_:_:)`](/documentation/Security/CMSDecoderCopySignerCert(_:_:_:)) functions to retrieve the certificates for a specific signer.

You cannot call this function until after you have called the [`CMSDecoderFinalizeMessage(_:)`](/documentation/Security/CMSDecoderFinalizeMessage(_:)) function.

## See Also

[`CMSDecoderCopySignerCert(_:_:_:)`](/documentation/Security/CMSDecoderCopySignerCert(_:_:_:))

Obtains the certificate of the specified signer of a CMS message.

[`CMSEncoderAddSupportingCerts(_:_:)`](/documentation/Security/CMSEncoderAddSupportingCerts(_:_:))

Adds certificates to a message.

[`CMSDecoderGetNumSigners(_:_:)`](/documentation/Security/CMSDecoderGetNumSigners(_:_:))

Obtains the number of signers of a message.

[`CMSDecoderCreate(_:)`](/documentation/Security/CMSDecoderCreate(_:))

Creates a CMSDecoder reference.

[`CMSDecoderFinalizeMessage(_:)`](/documentation/Security/CMSDecoderFinalizeMessage(_:))

Indicates that there is no more data to decode.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)