<!--
{
  "documentType" : "article",
  "framework" : "Security",
  "identifier" : "/documentation/Security/code-signing-services",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Code Signing Services"
}
-->

# Code Signing Services

Examine and validate signed code running on the system.

## Overview

Code signing is a macOS security technology that you use to certify that an app was created by you. Once an app is signed, the system can detect any change to the app—whether the change is introduced accidentally or by malicious code. You can control how your signed code loads signed plug-ins and other signed code without invalidating the signatures of the host code or of the guest (dynamically loaded) code.

You work with code objects that represent uniquely identified elements of running code in the system. In addition to UNIX processes, these elements can include scripts, applets, widgets, and so forth. You also work with *static* code objects that represent code in the file system. Static code includes applications, tools, frameworks, plug-ins, scripts, and so on. Generally, a code object has a specific static code object from which it originates and that holds its static signing data. The reverse, however, is not true—given a static code object, it is not possible to find, enumerate, or control any code object that originated from it.

## Topics

### Code Objects

Work with signed code loaded into memory.

[`class SecCode`](/documentation/Security/SecCode)

A code object representing signed code running on the system.

[`func SecCodeCopySelf(SecCSFlags, UnsafeMutablePointer<SecCode?>) -> OSStatus`](/documentation/Security/SecCodeCopySelf(_:_:))

Retrieves the code object for the code making the call.

[`struct SecCSFlags`](/documentation/Security/SecCSFlags)

Values that can be used in the `flags` parameter to most code signing functions.

[`func SecCodeGetTypeID() -> CFTypeID`](/documentation/Security/SecCodeGetTypeID())

Returns the unique identifier of the opaque type to which a code object belongs.

### Static Code

Work with signed code on disk.

[`class SecStaticCode`](/documentation/Security/SecStaticCode)

A static code object representing signed code on disk.

[`func SecStaticCodeCreateWithPath(CFURL, SecCSFlags, UnsafeMutablePointer<SecStaticCode?>) -> OSStatus`](/documentation/Security/SecStaticCodeCreateWithPath(_:_:_:))

Creates a static code object representing the code at a specified file system path.

[`func SecStaticCodeCreateWithPathAndAttributes(CFURL, SecCSFlags, CFDictionary, UnsafeMutablePointer<SecStaticCode?>) -> OSStatus`](/documentation/Security/SecStaticCodeCreateWithPathAndAttributes(_:_:_:_:))

Creates a static code object representing the code at a specified file system path using an attributes dictionary.

[Code Attributes](/documentation/Security/code-attributes)

Specify these keys from the attribute dictionary when you create a static code instance.

[`func SecStaticCodeGetTypeID() -> CFTypeID`](/documentation/Security/SecStaticCodeGetTypeID())

Returns the unique identifier of the opaque type to which a static code object belongs.

### Working with Code Objects

[`func SecCodeCopyPath(SecStaticCode, SecCSFlags, UnsafeMutablePointer<CFURL?>) -> OSStatus`](/documentation/Security/SecCodeCopyPath(_:_:_:))

Retrieves the location on disk of signed code, given a code or static code object.

[`func SecCodeCopyStaticCode(SecCode, SecCSFlags, UnsafeMutablePointer<SecStaticCode?>) -> OSStatus`](/documentation/Security/SecCodeCopyStaticCode(_:_:_:))

Returns a static code object representing the on-disk version of the given running code.

[Code Signing Architecture Flags](/documentation/Security/code-signing-architecture-flags)

Use these supplemental flags to get static code.

### Code Signatures

[`func SecCodeCopySigningInformation(SecStaticCode, SecCSFlags, UnsafeMutablePointer<CFDictionary?>) -> OSStatus`](/documentation/Security/SecCodeCopySigningInformation(_:_:_:))

Retrieves various pieces of information from a code signature.

[Code Signing Information Flags](/documentation/Security/code-signing-information-flags)

Use these supplemental flags to retrieve signing information.

[Signing Information Dictionary Keys](/documentation/Security/signing-information-dictionary-keys)

Use these keys from the information dictionary when you retrieve information from a code signature.

[`struct SecCodeSignatureFlags`](/documentation/Security/SecCodeSignatureFlags)

Specify option flags that can be embedded in a code signature during signing and that govern the use of the signature.

[`enum SecCSDigestAlgorithm`](/documentation/Security/SecCSDigestAlgorithm)

The list of digest algorithms available for code signatures.

### Code Requirements

[Applying Code Requirements](/documentation/Security/applying-code-requirements)

Manage the code requirements that apply to your signed code.

[`func SecCodeCopyDesignatedRequirement(SecStaticCode, SecCSFlags, UnsafeMutablePointer<SecRequirement?>) -> OSStatus`](/documentation/Security/SecCodeCopyDesignatedRequirement(_:_:_:))

Retrieves the designated code requirement of signed code.

[`class SecRequirement`](/documentation/Security/SecRequirement)

A code requirement object.

[`func SecRequirementGetTypeID() -> CFTypeID`](/documentation/Security/SecRequirementGetTypeID())

Returns the unique identifier of the opaque type to which a code requirement object belongs.

[`enum SecRequirementType`](/documentation/Security/SecRequirementType)

An enumeration indicating different types of internal requirements for code.

### Code Requirements as Data

[`func SecRequirementCopyData(SecRequirement, SecCSFlags, UnsafeMutablePointer<CFData?>) -> OSStatus`](/documentation/Security/SecRequirementCopyData(_:_:_:))

Extracts a binary form of a code requirement from a code requirement object.

[`func SecRequirementCreateWithData(CFData, SecCSFlags, UnsafeMutablePointer<SecRequirement?>) -> OSStatus`](/documentation/Security/SecRequirementCreateWithData(_:_:_:))

Creates a code requirement object from the binary form of a code requirement.

### Code Requirements as Text

[`func SecRequirementCopyString(SecRequirement, SecCSFlags, UnsafeMutablePointer<CFString?>) -> OSStatus`](/documentation/Security/SecRequirementCopyString(_:_:_:))

Converts a code requirement object into text form.

[`func SecRequirementCreateWithString(CFString, SecCSFlags, UnsafeMutablePointer<SecRequirement?>) -> OSStatus`](/documentation/Security/SecRequirementCreateWithString(_:_:_:))

Creates a code requirement object by compiling a valid text representation of a code requirement.

[`func SecRequirementCreateWithStringAndErrors(CFString, SecCSFlags, UnsafeMutablePointer<Unmanaged<CFError>?>?, UnsafeMutablePointer<SecRequirement?>) -> OSStatus`](/documentation/Security/SecRequirementCreateWithStringAndErrors(_:_:_:_:))

Creates a code requirement object by compiling a valid text representation of a code requirement and returns detailed error information in the case of failure.

### Guest Code

[Hosting Guest Code](/documentation/Security/hosting-guest-code)

Securely launch and manage plug-ins and other executable entities, known as guest code, from within your app acting as a host.

[`OSStatus SecHostCreateGuest(SecGuestRef host, uint32_t status, CFURLRef path, CFDictionaryRef attributes, SecCSFlags flags, SecGuestRef *newGuest);`](/documentation/Security/SecHostCreateGuest)

Creates a new guest and describes its initial properties.

[`OSStatus SecHostSetGuestStatus(SecGuestRef guestRef, uint32_t status, CFDictionaryRef attributes, SecCSFlags flags);`](/documentation/Security/SecHostSetGuestStatus)

Updates the status and attributes of a particular guest.

[`func SecCodeCopyGuestWithAttributes(SecCode?, CFDictionary?, SecCSFlags, UnsafeMutablePointer<SecCode?>) -> OSStatus`](/documentation/Security/SecCodeCopyGuestWithAttributes(_:_:_:_:))

Asks a code host to identify one of its guests given the type and value of specific attributes of the guest code.

[Null Guest Handle](/documentation/Security/null-guest-handle)

Use this special value to stand in for a null guest object.

[`struct SecCodeStatus`](/documentation/Security/SecCodeStatus)

Operational flags attached by code signing services to running code.

[Guest Creation Flags](/documentation/Security/guest-creation-flags)

Use these supplemental flags to create a guest object.

[Guest Attribute Dictionary Keys](/documentation/Security/guest-attribute-dictionary-keys)

Specify attributes of guest code.

[`typealias SecGuestRef`](/documentation/Security/SecGuestRef)

A reference to a guest object, which identifies a particular block of guest code in the context of its code signing host.

### Guest Management

[`func SecCodeCopyHost(SecCode, SecCSFlags, UnsafeMutablePointer<SecCode?>) -> OSStatus`](/documentation/Security/SecCodeCopyHost(_:_:_:))

Retrieves the code object for the host of specified guest code.

[`OSStatus SecHostRemoveGuest(SecGuestRef host, SecGuestRef guest, SecCSFlags flags);`](/documentation/Security/SecHostRemoveGuest)

Removes a guest from a host.

[`OSStatus SecHostSelectGuest(SecGuestRef guestRef, SecCSFlags flags);`](/documentation/Security/SecHostSelectGuest)

Makes the calling thread the proxy for a specified guest.

[`OSStatus SecHostSelectedGuest(SecCSFlags flags, SecGuestRef *guestRef);`](/documentation/Security/SecHostSelectedGuest)

Retrieves the handle for the guest currently selected for the calling thread.

[`OSStatus SecHostSetHostingPort(mach_port_t hostingPort, SecCSFlags flags);`](/documentation/Security/SecHostSetHostingPort)

Tells code signing services that the calling code will directly respond to hosting inquiries over the given port.

[`func SecCodeMapMemory(SecStaticCode, SecCSFlags) -> OSStatus`](/documentation/Security/SecCodeMapMemory(_:_:))

Asks the kernel to accept the signing information currently attached to a code object and uses it to validate memory page-ins.

### Tasks

[`func SecTaskCreateFromSelf(CFAllocator?) -> SecTask?`](/documentation/Security/SecTaskCreateFromSelf(_:))

Creates a task object for the current task.

[`func SecTaskCreateWithAuditToken(CFAllocator?, audit_token_t) -> SecTask?`](/documentation/Security/SecTaskCreateWithAuditToken(_:_:))

Creates a task object for the task that sent the Mach message represented by the audit token.

[`class SecTask`](/documentation/Security/SecTask)

The Core Foundation type representing a task.

[`func SecTaskGetTypeID() -> CFTypeID`](/documentation/Security/SecTaskGetTypeID())

Returns the unique identifier of the opaque type to which a task object belongs.

[`func SecTaskCopySigningIdentifier(SecTask, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> CFString?`](/documentation/Security/SecTaskCopySigningIdentifier(_:_:))

Returns the value of the code signing identifier.

[`func SecTaskCopyValueForEntitlement(SecTask, CFString, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> CFTypeRef?`](/documentation/Security/SecTaskCopyValueForEntitlement(_:_:_:))

Returns the value of a single entitlement for the represented task.

[`func SecTaskCopyValuesForEntitlements(SecTask, CFArray, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> CFDictionary?`](/documentation/Security/SecTaskCopyValuesForEntitlements(_:_:_:))

Returns the values of multiple entitlements for the represented task.

### Code Signature Validity

[`func SecCodeCheckValidity(SecCode, SecCSFlags, SecRequirement?) -> OSStatus`](/documentation/Security/SecCodeCheckValidity(_:_:_:))

Performs dynamic validation of signed code.

[`func SecCodeCheckValidityWithErrors(SecCode, SecCSFlags, SecRequirement?, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> OSStatus`](/documentation/Security/SecCodeCheckValidityWithErrors(_:_:_:_:))

Performs dynamic validation of signed code and returns detailed error information in the case of failure.

[`func SecStaticCodeCheckValidity(SecStaticCode, SecCSFlags, SecRequirement?) -> OSStatus`](/documentation/Security/SecStaticCodeCheckValidity(_:_:_:))

Validates a static code object.

[`func SecStaticCodeCheckValidityWithErrors(SecStaticCode, SecCSFlags, SecRequirement?, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> OSStatus`](/documentation/Security/SecStaticCodeCheckValidityWithErrors(_:_:_:_:))

Performs static validation of static signed code and returns detailed error information in the case of failure.

[Static Code Validation Flags](/documentation/Security/static-code-validation-flags)

Use these supplemental flags to test the validity of a static code signature.

### Result Codes

[Code Signing Services Result Codes](/documentation/Security/code-signing-services-result-codes)

Recognize result codes specific to the code signing services API.

[User Info Dictionary Error Keys](/documentation/Security/user-info-dictionary-error-keys)

Recognize the keys of the user info dictionary provided by functions that return error objects.

## See Also

  [Code Signing Guide](https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005929)



---

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)