iOS里加载https请求报错说服务器证书无效的解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。联系博主:QQ群:①群:446310206 ②群:426087546(付费群,介意勿加) https://blog.csdn.net/qq_31810357/article/details/84523140
NSURLConnectionDelegate

- (void)loadUnioPage:(UIWebView*)MobileLoadWebView
{
    NSURL *LoadURL = [NSURL URLWithString:self.confirm_url];
    NSURLRequest *request = [NSURLRequest requestWithURL:LoadURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:25];
    [NSURLConnection connectionWithRequest:request delegate:self];
    [MobileLoadWebView loadRequest:request];
}
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
        [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
        [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
    }
}

猜你喜欢

转载自blog.csdn.net/qq_31810357/article/details/84523140