Skip to content

Commit 7594425

Browse files
author
Pavel Osipov
committed
Implement 'SDWebImageDownloaderAllowInvalidSSLCertificates' option.
1 parent d2da4d0 commit 7594425

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

SDWebImage/SDWebImageDownloaderOperation.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,13 @@ - (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connect
396396

397397
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
398398
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
399-
NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
400-
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
399+
if (!(self.options & SDWebImageDownloaderAllowInvalidSSLCertificates) &&
400+
[challenge.sender respondsToSelector:@selector(performDefaultHandlingForAuthenticationChallenge:)]) {
401+
[challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
402+
} else {
403+
NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
404+
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
405+
}
401406
} else {
402407
if ([challenge previousFailureCount] == 0) {
403408
if (self.credential) {

0 commit comments

Comments
 (0)