我对 iOS 上的扩展 SSL 证书验证有疑问。我的代码如下所示:
- (void) validateAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if (!someCustomCheck()) { // I do some custom check here
[paramChallenge.sender cancelAuthenticationChallenge:challenge];
}
NSURLCredential *credential = [NSURLCredential credentialForTrust:[challenge protectionSpace].serverTrust];
if (credential) {
[challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
}
else {
[challenge.sender cancelAuthenticationChallenge:challenge];
}
}
测试告诉我,此时没有发生对 SSL 证书的正常 iOS 检查。我可以假设如果我替换该行:
[challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
和
[challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
所以在我的自定义检查之后,我仍然会有默认的系统 SSL 证书检查吗?
从文档中看是有道理的,但是我见过的许多示例通常会进行一些自定义验证,然后调用
[challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
谢谢。