From 706c57308e6d3af422dd375cc35bd058be7dbc34 Mon Sep 17 00:00:00 2001 From: Jens Andersson Date: Wed, 11 Dec 2013 16:26:08 +0100 Subject: [PATCH] Cleaned up code to follow project code style --- SDWebImage/SDWebImageDownloader.h | 6 +++--- SDWebImage/SDWebImageDownloaderOperation.m | 9 ++++++--- SDWebImage/SDWebImageManager.h | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index ae7cfd7..3d0921c 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -34,11 +34,11 @@ typedef enum * NSMutableURLRequest.HTTPShouldHandleCookies = YES; */ SDWebImageDownloaderHandleCookies = 1 << 5, - SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6 /** - * Enable this to allow untrusted SSL ceriticates. - * Useful for testing purposes. + * Enable to allow untrusted SSL ceriticates. + * Useful for testing purposes. Use with caution in production. */ + SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6 } SDWebImageDownloaderOptions; diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index da21082..e019600 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -371,13 +371,16 @@ return self.options & SDWebImageDownloaderContinueInBackground; } -- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { +- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace +{ return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; } -- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { +- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ BOOL trustAllCertificates = (self.options & SDWebImageDownloaderAllowInvalidSSLCertificates); - if (trustAllCertificates && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if (trustAllCertificates && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) + { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; } diff --git a/SDWebImage/SDWebImageManager.h b/SDWebImage/SDWebImageManager.h index 39a11a7..688d457 100644 --- a/SDWebImage/SDWebImageManager.h +++ b/SDWebImage/SDWebImageManager.h @@ -52,11 +52,11 @@ typedef enum * NSMutableURLRequest.HTTPShouldHandleCookies = YES; */ SDWebImageHandleCookies = 1 << 6, - SDWebImageAllowInvalidSSLCertificates = 1 << 7 /** - * Enable this to allow untrusted SSL ceriticates. - * Useful for testing purposes. + * Enable to allow untrusted SSL ceriticates. + * Useful for testing purposes. Use with caution in production. */ + SDWebImageAllowInvalidSSLCertificates = 1 << 7 } SDWebImageOptions; typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType);