I\'m trying to figure out what iOS\' policy is when verifying certificates using Security.Framework regarding revocation of certificates. I cannot find information about thi
I was able to enable CRL checking for a SecTrustRef
object on iOS 10:
SecTrustRef trust = ...; // from TLS challenge
CFArrayRef oldPolicies;
SecTrustCopyPolicies(trust, &oldPolicies);
SecPolicyRef revocationPolicy = SecPolicyCreateRevocation(kSecRevocationCRLMethod);
NSArray *newPolicies = [(__bridge NSArray *)oldPolicies arrayByAddingObject(__bridge id)revocationPolicy];
CFRelease(oldPolicies);
SecTrustSetPolicies(trust, (__bridge CFArrayRef)newPolicies);
SecTrustSetNetworkFetchAllowed(trust, true);
// Check the trust object
SecTrustResult result = kSecTrustResultInvalid;
SecTrustEvaluate(trust, &result);
// cert revoked -> kSecTrustResultRecoverableTrustFailure
Calling SecTrustSetNetworkFetchAllowed
was key. Without that call, SecTrustEvaluate
returned kSecTrustResultUnspecified
instead.
I just did this on iOS in GCDAsyncSocket.
For a given SecTrustRef trust; do this
SecPolicyRef policy = SecPolicyCreateRevocation(kSecRevocationOCSPMethod)
SecTrustSetPolicies(trust, policy);
SecTrustResultType trustResultType = kSecTrustResultInvalid;
OSStatus status = SecTrustEvaluate(trust, &trustResultType);
if (status == errSecSuccess && trustResultType == kSecTrustResultProceed)
{
//good!
}
else
{
//not good
}
//edit to check the trustResultType
I have an answer to this question by Apple guys, I posted the full answer here:
Details on SSL/TLS certificate revocation mechanisms on iOS
To sum it up, there are several things to keep in mind for OCSP implementation on iOS: