---
title: "SecCertificateCopyPublicKey(_:)"
framework: security
role: symbol
role_heading: Function
path: "security/seccertificatecopypublickey(_:_:)"
---

# SecCertificateCopyPublicKey(_:)

Retrieves the public key from a certificate.

## Declaration

```swift
func SecCertificateCopyPublicKey(_ certificate: SecCertificate) -> SecKey?
```

```swift
func SecCertificateCopyPublicKey(_ certificate: SecCertificate, _ key: UnsafeMutablePointer<SecKey?>) -> OSStatus
```

## Parameters

- `certificate`: The certificate object from which to retrieve the public key.
- `key`: In macOS, points to the public key for the specified certificate. In Objective-C, call the doc://com.apple.documentation/documentation/CoreFoundation/CFRelease function to release this object when you are finished with it.

## Mentioned in

Examining a Certificate

## Return Value

Return Value In iOS, the certificate’s public key.

## Discussion

Discussion In macOS, a result code. See Security Framework Result Codes.
