Skip to content

Instantly share code, notes, and snippets.

@NSProgrammer
Created September 2, 2019 18:11
Show Gist options
  • Save NSProgrammer/fc7665f84d05573d4d93312463f57233 to your computer and use it in GitHub Desktop.
Save NSProgrammer/fc7665f84d05573d4d93312463f57233 to your computer and use it in GitHub Desktop.
static OSStatus WrapperSecTrustEvaluate(SecTrustRef serverTrust, SecTrustResultType *result)
{
if (@available(iOS 13, *)) {
// SecTrustEvaluate is deprecated.
// Wrap new API to have same calling pattern as we had prior to deprecation.
// 1) call the new function to execut the evaluation
CFErrorRef error = NULL;
const bool evaluationSucceeded = SecTrustEvaluateWithError(serverTrust, &error);
// 2) We don't actually care about the evaluation here, since we will get the result and key off that.
if (!evaluationSucceeded) {
CFRelease(error);
}
// 3) call the "get trust result" to yield the result just like the old function
return SecTrustGetTrustResult(serverTrust, result);
} else {
return SecTrustEvaluate(serverTrust, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment