---
title: SecCertificateCreateFromData
framework: security
role: symbol
role_heading: Function
path: security/seccertificatecreatefromdata
---

# SecCertificateCreateFromData

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

## Declaration

```occ
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

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

## Discussion

Discussion important: This function is deprecated. Use SecCertificateCreateWithData(_:_:) instead. The certificate object returned by this function is used as input to several other functions in the API.
