---
title: "CMSEncoderSetCertificateChainMode(_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/cmsencodersetcertificatechainmode(_:_:)"
---

# CMSEncoderSetCertificateChainMode(_:_:)

Specifies which certificates to include in a signed CMS message.

## Declaration

```swift
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 doc://com.apple.security/documentation/Security/CMSCertificateChainMode.

## Return Value

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

## Discussion

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

### Related Documentation

- [CMSEncoderUpdateContent(_:_:_:)](security/cmsencoderupdatecontent(_:_:_:).md)
- [CMSEncoderGetCertificateChainMode(_:_:)](security/cmsencodergetcertificatechainmode(_:_:).md)
- [CMSEncoderCreate(_:)](security/cmsencodercreate(_:).md)
