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


func SecCodeCheckValidityWithErrors(_ code: SecCode, _ flags: SecCSFlags, _ requirement: SecRequirement?, _ errors: UnsafeMutablePointer<Unmanaged<CFError>?>?) -> OSStatus



The code object to be validated.


Optional flags; see SecCSFlags for possible values. Pass kSecCSDefaultFlags for standard behavior.


A code requirement specifying additional conditions the code must satisfy to be considered valid. Specify NULL if you don’t want to impose any additional requirements. Use the SecRequirementCreateWithString(_:_:_:) or SecRequirementCreateWithStringAndErrors(_:_:_:_:) function to create a code requirement object. See Code Signing Guide for a discussion of code requirements.


On return, if the function call fails and returns a result code other than errSecSuccess, points to an error object further describing the nature and circumstances of the failure. Use the CFErrorCopyUserInfo(_:) function to retrieve the user info dictionary from the error object. See User Info Dictionary Error Keys for possible values. Pass NULL if you do not want this information. Call the CFRelease function to release this object when you are finished with it.

Return Value


This function obtains and verifies the signature on the code specified by the code object. It checks the validity of only those sealed components required to establish identity. For guest code, first the function checks the code object’s dynamic validity status as reported by its host, then it ensures that the code object’s host is in turn valid. For all code, it validates the code against a code requirement if one is specified. The call succeeds if all these conditions are satisfactory.

This function is secure against attempts to modify the file system source of the code object.

See Also

Code Signature Validity

func SecStaticCodeCheckValidityWithErrors(SecStaticCode, SecCSFlags, SecRequirement?, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> OSStatus

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

Static Code Validation Flags

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