NSURLConnection与自定义SSL验证

时间:2013-11-01 15:57:43

标签: ios ssl nsurlconnection

我对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];

感谢。

0 个答案:

没有答案