---
title: "CMSEncoderAddRecipients(_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/cmsencoderaddrecipients(_:_:)"
---

# CMSEncoderAddRecipients(_:_:)

Specifies a message is to be encrypted and specifies the recipients of the message.

## Declaration

```swift
func CMSEncoderAddRecipients(_ cmsEncoder: CMSEncoder, _ recipientOrArray: CFTypeRef) -> OSStatus
```

## Parameters

- `cmsEncoder`: The CMSEncoder reference returned by the CMSEncoderCreate function.
- `recipientOrArray`: Either a single certificate containing a public encryption key for one message recipient, specified as a certificate object (type doc://com.apple.security/documentation/Security/SecCertificate), or a set of certificates specified as a doc://com.apple.documentation/documentation/CoreFoundation/CFArray of certificate objects.

## Return Value

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

## Discussion

Discussion Your keychain must contain a certificate that supports encryption for each recipient. You can call this function more than once for the same message. You can both sign and encrypt the same message; however, you cannot call both this function and the CMSEncoderSetHasDetachedContent(_:_:) function for the same message. 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)
- [CMSEncoderCreate(_:)](security/cmsencodercreate(_:).md)
- [CMSEncoderCopyRecipients(_:_:)](security/cmsencodercopyrecipients(_:_:).md)
- [CMSDecoderIsContentEncrypted(_:_:)](security/cmsdecoderiscontentencrypted(_:_:).md)
