<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.7.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecCertificateCreateFromData",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecCertificateCreateFromData"
  },
  "title" : "SecCertificateCreateFromData"
}
-->

# SecCertificateCreateFromData

Creates a certificate object based on the specified data, type, and encoding.

```
OSStatus SecCertificateCreateFromData(const SecAsn1Item *data, CSSM_CERT_TYPE type, CSSM_CERT_ENCODING encoding, SecCertificateRef*certificate);
```

## Parameters

`data`

A pointer to the certificate data. The data must be an X509 certificate in binary format.

`type`

The certificate type as defined in `Security.framework/cssmtype.h`. Permissible values are `CSSM_CERT_X_509v1`, `CSSM_CERT_X_509v2`, and `CSSM_CERT_X_509v3`. If you are unsure of the certificate type, use `CSSM_CERT_X_509v3`.

`encoding`

The certificate encoding as defined in `Security.framework/cssmtype.h`. Permissible values are `CSSM_CERT_ENCODING_BER` and `CSSM_CERT_ENCODING_DER`. If you are unsure of the encoding, use `CSSM_CERT_ENCODING_BER`.

`certificate`

On return, points to the newly created certificate object. In Objective-C, call the <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> function to release this object when you are finished with it.

## Return Value

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

## Discussion

> Important:
> This function is deprecated.
> Use ``doc://com.apple.security/documentation/Security/SecCertificateCreateWithData(_:_:)`` instead.

The certificate object returned by this function is used as input to several other functions in the API.

---

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)