Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func codeCheck() -> Bool
- {
- var myCode : SecCode?
- var status : OSStatus?
- var requirement : SecRequirement?
- var errors : Unmanaged<CFError>?
- let entitlement = "anchor apple generic and identifier = \"com.yourapp.example\" and certificate leaf[subject.OU] = Y0URTEAM1D"
- status = SecRequirementCreateWithStringAndErrors(entitlement as CFString, [], &errors, &requirement)
- if status != errSecSuccess
- {
- NSLog("SecRequirements failed with status code \(status).")
- } else
- {
- status = SecCodeCopySelf([], &myCode)
- if status != errSecSuccess
- {
- NSLog("SecCodeCopySelf failed with status code: \(status).")
- } else
- {
- status = SecCodeCheckValidity(myCode!, [], requirement)
- if status != errSecSuccess
- {
- NSLog("SecCodeCheckValidity failed with status code: \(status).")
- } else
- {
- NSLog("Codesigning: valid")
- return true
- }
- }
- }
- return false
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement