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

# CMSEncoderAddRecipients(_:_:)

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

```
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 [`SecCertificate`](/documentation/Security/SecCertificate)), or a set of certificates specified as a <doc://com.apple.documentation/documentation/CoreFoundation/CFArray> of certificate objects.

## Return Value

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

## 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(_:_:)`](/documentation/Security/CMSEncoderSetHasDetachedContent(_:_:)) function for the same message.

If you do call this function, you must call it before the first call to the [`CMSEncoderUpdateContent(_:_:_:)`](/documentation/Security/CMSEncoderUpdateContent(_:_:_:)) function.

## See Also

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

Feeds content bytes into the encoder.

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

Creates a CMSEncoder reference.

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

Obtains the array of recipients specified with the `CMSEncoderAddRecipients` function.

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

Determines whether a CMS message was encrypted.



---

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)