Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(BOOL)codeCheck
- {
- CFErrorRef errors = NULL;
- SecCodeRef myCode = NULL;
- SecRequirementRef requirement = NULL;
- OSStatus status = errSecSuccess;
- status = SecCodeCopySelf(kSecCSDefaultFlags, &myCode);
- if (status != errSecSuccess)
- {
- NSLog(@"SecCodeCopySelf failed with status code: %ld", (long)status);
- }
- NSString *entitlement = @"anchor apple generic and identifier = \"com.yourapp.example\" and certificate leaf[subject.OU] = Y0URTEAM1D";
- status = SecRequirementCreateWithStringAndErrors((__bridge CFStringRef)entitlement, kSecCSDefaultFlags, &errors, &requirement);
- if (status != errSecSuccess)
- {
- NSLog(@"SecRequirements failed with status code %i", status);
- // optionally unpack errors here
- } else
- {
- status = SecCodeCheckValidity(myCode, kSecCSDefaultFlags, requirement);
- if (status != errSecSuccess)
- {
- NSLog(@"SecCodeCheckValidity failed with status code %i", status);
- } else {
- return YES;
- }
- }
- return NO;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement