- policy = SecPolicyCreateWithProperties(kSecPolicyAppleRevocation, NULL);
- if (policy) {
- CFArrayAppendValue(resultPolicyArray, policy);
- CFReleaseNull(policy);
+
+ /* check the provided argument for a revocation policy */
+ CFMutableArrayRef policies = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ if (policies && policyOrArray) {
+ if (CFGetTypeID(policyOrArray) == SecPolicyGetTypeID()) {
+ CFArrayAppendValue(policies, policyOrArray);
+ } else if (CFGetTypeID(policyOrArray) == CFArrayGetTypeID()) {
+ CFIndex arrayLength = CFArrayGetCount((CFArrayRef)policyOrArray);
+ CFArrayAppendArray(policies, (CFArrayRef)policyOrArray, CFRangeMake(0, arrayLength));
+ }
+ }
+ CFIndex numPolicies = (policies) ? CFArrayGetCount(policies) : 0;
+ for (CFIndex index=0; index<numPolicies; index++) {
+ SecPolicyRef policy = (SecPolicyRef)CFArrayGetValueAtIndex(policies, index);
+ CFStringRef policyName = (policy) ? SecPolicyGetName(policy) : NULL;
+ if (policyName && CFEqual(CFSTR("revocation"), policyName)) {
+ CFArrayAppendValue(resultPolicyArray, policy);
+ }