From 75944258f0110ac0d4e97ac8a04c7b53225eb5c0 Mon Sep 17 00:00:00 2001 From: Pavel Osipov Date: Thu, 23 Oct 2014 17:16:28 +0400 Subject: [PATCH] Implement 'SDWebImageDownloaderAllowInvalidSSLCertificates' option. --- SDWebImage/SDWebImageDownloaderOperation.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 333e316b..c5696979 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -396,8 +396,13 @@ - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{ if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + if (!(self.options & SDWebImageDownloaderAllowInvalidSSLCertificates) && + [challenge.sender respondsToSelector:@selector(performDefaultHandlingForAuthenticationChallenge:)]) { + [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge]; + } else { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } } else { if ([challenge previousFailureCount] == 0) { if (self.credential) {