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

# SecCertificateCopySerialNumber(_:)

Returns a copy of a certificate’s serial number.

```
func SecCertificateCopySerialNumber(_ certificate: SecCertificate) -> CFData?
```

## Parameters

`certificate`

The certificate from which the serial number should be copied.

`error`

A pointer to a <doc://com.apple.documentation/documentation/CoreFoundation/CFError> variable where an error object is stored upon failure. If not `NULL`, the caller is responsible for checking this variable and releasing the resulting object if it exists.

## Return Value

A data instance containing a DER-encoded integer for the certificate’s serial number (without the tag and length fields) or `nil` if an error occurred. In Objective-C, free this object with a call to <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> when you are done with it.

---

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)