Merge pull request #582 from jenshandersson/master
Added new option to allow invalid SSL Certificates. Useful for testing
This commit is contained in:
commit
4382672c4a
|
@ -33,7 +33,12 @@ typedef enum
|
|||
* Handles cookies stored in NSHTTPCookieStore by setting
|
||||
* NSMutableURLRequest.HTTPShouldHandleCookies = YES;
|
||||
*/
|
||||
SDWebImageDownloaderHandleCookies = 1 << 5
|
||||
SDWebImageDownloaderHandleCookies = 1 << 5,
|
||||
/**
|
||||
* Enable to allow untrusted SSL ceriticates.
|
||||
* Useful for testing purposes. Use with caution in production.
|
||||
*/
|
||||
SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6
|
||||
|
||||
} SDWebImageDownloaderOptions;
|
||||
|
||||
|
|
|
@ -371,5 +371,21 @@
|
|||
return self.options & SDWebImageDownloaderContinueInBackground;
|
||||
}
|
||||
|
||||
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
|
||||
{
|
||||
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
|
||||
{
|
||||
BOOL trustAllCertificates = (self.options & SDWebImageDownloaderAllowInvalidSSLCertificates);
|
||||
if (trustAllCertificates && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
|
||||
{
|
||||
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]
|
||||
forAuthenticationChallenge:challenge];
|
||||
}
|
||||
|
||||
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -51,7 +51,12 @@ typedef enum
|
|||
* Handles cookies stored in NSHTTPCookieStore by setting
|
||||
* NSMutableURLRequest.HTTPShouldHandleCookies = YES;
|
||||
*/
|
||||
SDWebImageHandleCookies = 1 << 6
|
||||
SDWebImageHandleCookies = 1 << 6,
|
||||
/**
|
||||
* 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);
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache;
|
||||
if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground;
|
||||
if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies;
|
||||
if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates;
|
||||
if (image && options & SDWebImageRefreshCached)
|
||||
{
|
||||
// force progressive off if image already cached but forced refreshing
|
||||
|
|
Loading…
Reference in New Issue