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

# CMSEncoderCreate(_:)

Creates a CMSEncoder reference.

```
func CMSEncoderCreate(_ cmsEncoderOut: UnsafeMutablePointer<CMSEncoder?>) -> OSStatus
```

## Parameters

`cmsEncoderOut`

On return, points to a CMSEncoder reference. 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

This is the first function in a sequence of encoder functions that you call to sign or encrypt a message. The other functions in the sequence require you to pass in the CMSEncoder reference returned by this function. In many cases, you can call the [`CMSEncode`](/documentation/Security/CMSEncode) function alone instead of this sequence of encoder functions.

---

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)