<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecCertificateCopySerialNumberData(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecCertificateCopySerialNumberData"
  },
  "title" : "SecCertificateCopySerialNumberData(_:_:)"
}
-->

# SecCertificateCopySerialNumberData(_:_:)

Returns the certificate’s serial number.

```
func SecCertificateCopySerialNumberData(_ certificate: SecCertificate, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>?) -> CFData?
```

## Parameters

`certificate`

The certificate from which to copy the serial number.

`error`

A <doc://com.apple.documentation/documentation/CoreFoundation/CFError> pointer the function uses to return an error instance on failure. Set to `nil` to ignore any error.

## Return Value

The content of a DER-encoded integer (without the tag and length fields) for this certificate’s serial number.

## Discussion

In Objective-C, if the function returns an error free it with a call to <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> when you are done with it. If it returns data, you must free that as well.

---

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)