---
title: "SecCertificateCopySerialNumber(_:)"
framework: security
role: symbol
role_heading: Function
path: "security/seccertificatecopyserialnumber(_:_:)"
---

# SecCertificateCopySerialNumber(_:)

Returns a copy of a certificate’s serial number.

## Declaration

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

```swift
func SecCertificateCopySerialNumber(_ certificate: SecCertificate, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>?) -> 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

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 CFRelease when you are done with it.
