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

# CMSEncoderSetCertificateChainMode(_:_:)

Specifies which certificates to include in a signed CMS message.

```
func CMSEncoderSetCertificateChainMode(_ cmsEncoder: CMSEncoder, _ chainMode: CMSCertificateChainMode) -> OSStatus
```

## Parameters

`cmsEncoder`

The CMSEncoder reference returned by the `CMSEncoderCreate` function.

`chainMode`

A constant that indicates which certificate or certificates to include in the message. See [`CMSCertificateChainMode`](/documentation/Security/CMSCertificateChainMode).

## Return Value

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

## Discussion

This function is used only for signed messages and is optional. If you don’t call this function, the default, `kCMSCertificateChain`, is used. In this case the message includes the signer certificate plus all certificates needed to verify the signer certificate, up to but not including the root  certificate.

If you do call this function, you must call it before the first call to the `CMSEncoderUpdateContent` function.

## See Also

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

Feeds content bytes into the encoder.

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

Obtains a constant that indicates which certificates are to be included in a signed CMS message.

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

Creates a CMSEncoder reference.



---

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)