Skip to content

Commit

Permalink
Merge branch 'master' into fixed_memory_leaks
Browse files Browse the repository at this point in the history
* master:
  Update HTTPBin certificates
  Update HTTPBin certificates, good through December 2018.
  Removed redundant switch case
  Code cleaning
  • Loading branch information
svoit committed Feb 12, 2019
2 parents 96a52fa + ee95094 commit 73ef609
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 24 deletions.
16 changes: 8 additions & 8 deletions AFNetworking.xcodeproj/project.pbxproj
Expand Up @@ -16,9 +16,9 @@
1F6F7DFB1F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; };
1F6F7DFD1F17051100C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; };
1F6F7DFE1F17051100C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; };
1F73A747211B6C0C00AFCFA5 /* httpbinorg_10102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F73A746211B6C0C00AFCFA5 /* httpbinorg_10102018.cer */; };
1F73A748211B6C0C00AFCFA5 /* httpbinorg_10102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F73A746211B6C0C00AFCFA5 /* httpbinorg_10102018.cer */; };
1F73A749211B6C0C00AFCFA5 /* httpbinorg_10102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F73A746211B6C0C00AFCFA5 /* httpbinorg_10102018.cer */; };
1F8482C0220F386200718111 /* httpbinorg_04082019.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F8482BF220F386200718111 /* httpbinorg_04082019.cer */; };
1F8482C1220F386200718111 /* httpbinorg_04082019.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F8482BF220F386200718111 /* httpbinorg_04082019.cer */; };
1F8482C2220F386200718111 /* httpbinorg_04082019.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F8482BF220F386200718111 /* httpbinorg_04082019.cer */; };
1F96D2A4203649560085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F96D2A5203649570085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F96D2A6203649570085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -236,7 +236,7 @@
1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFCompatibilityMacros.h; sourceTree = "<group>"; };
1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Let's Encrypt Authority X3.cer"; sourceTree = "<group>"; };
1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DST Root CA X3.cer"; sourceTree = "<group>"; };
1F73A746211B6C0C00AFCFA5 /* httpbinorg_10102018.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = httpbinorg_10102018.cer; sourceTree = "<group>"; };
1F8482BF220F386200718111 /* httpbinorg_04082019.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = httpbinorg_04082019.cer; sourceTree = "<group>"; };
2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFUIButtonTests.m; sourceTree = "<group>"; };
297824A01BC2D69A0041C395 /* adn_0.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_0.cer; path = ADNNetServerTrustChain/adn_0.cer; sourceTree = "<group>"; };
297824A11BC2D69A0041C395 /* adn_1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_1.cer; path = ADNNetServerTrustChain/adn_1.cer; sourceTree = "<group>"; };
Expand Down Expand Up @@ -412,7 +412,7 @@
298D7CE21BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain */,
1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */,
1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */,
1F73A746211B6C0C00AFCFA5 /* httpbinorg_10102018.cer */,
1F8482BF220F386200718111 /* httpbinorg_04082019.cer */,
);
path = HTTPBin.org;
sourceTree = "<group>";
Expand Down Expand Up @@ -851,6 +851,7 @@
files = (
2987B0DE1BC40AFB00179A4C /* foobar.com.cer in Resources */,
2987B0D61BC40AEC00179A4C /* ADNNetServerTrustChain in Resources */,
1F8482C2220F386200718111 /* httpbinorg_04082019.cer in Resources */,
2987B0DF1BC40AFB00179A4C /* NoDomains.cer in Resources */,
2987B0D41BC40AE900179A4C /* adn_1.cer in Resources */,
2987B0DD1BC40AFB00179A4C /* AltName.cer in Resources */,
Expand All @@ -864,7 +865,6 @@
5F4323BD1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */,
5F4323DF1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */,
5F4323C01BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */,
1F73A749211B6C0C00AFCFA5 /* httpbinorg_10102018.cer in Resources */,
1F6F7DFD1F17051100C979D0 /* DST Root CA X3.cer in Resources */,
5F4323CF1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */,
5F4323C31BF63741003B8749 /* google.com.cer in Resources */,
Expand All @@ -877,6 +877,7 @@
files = (
298D7CBF1BC2CA9D00FD3B3E /* foobar.com.cer in Resources */,
298D7CBA1BC2CA9800FD3B3E /* logo.png in Resources */,
1F8482C0220F386200718111 /* httpbinorg_04082019.cer in Resources */,
297824A31BC2D69A0041C395 /* adn_0.cer in Resources */,
298D7CE31BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain in Resources */,
297824A71BC2D69A0041C395 /* adn_2.cer in Resources */,
Expand All @@ -890,7 +891,6 @@
5F4323BB1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */,
5F4323DD1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */,
5F4323BE1BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */,
1F73A747211B6C0C00AFCFA5 /* httpbinorg_10102018.cer in Resources */,
1F6F7DF71F17051000C979D0 /* DST Root CA X3.cer in Resources */,
5F4323CD1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */,
5F4323C11BF63741003B8749 /* google.com.cer in Resources */,
Expand All @@ -903,6 +903,7 @@
files = (
298D7CBC1BC2CA9C00FD3B3E /* foobar.com.cer in Resources */,
298D7CB91BC2CA9800FD3B3E /* logo.png in Resources */,
1F8482C1220F386200718111 /* httpbinorg_04082019.cer in Resources */,
297824A41BC2D69A0041C395 /* adn_0.cer in Resources */,
298D7CE41BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain in Resources */,
297824A81BC2D69A0041C395 /* adn_2.cer in Resources */,
Expand All @@ -916,7 +917,6 @@
5F4323BC1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */,
5F4323CE1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */,
5F4323DE1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */,
1F73A748211B6C0C00AFCFA5 /* httpbinorg_10102018.cer in Resources */,
1F6F7DFA1F17051000C979D0 /* DST Root CA X3.cer in Resources */,
5F4323BF1BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */,
5F4323C21BF63741003B8749 /* google.com.cer in Resources */,
Expand Down
6 changes: 3 additions & 3 deletions AFNetworking/AFSecurityPolicy.m
Expand Up @@ -252,9 +252,6 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
}

switch (self.SSLPinningMode) {
case AFSSLPinningModeNone:
default:
return NO;
case AFSSLPinningModeCertificate: {
NSMutableArray *pinnedCertificates = [NSMutableArray array];
for (NSData *certificateData in self.pinnedCertificates) {
Expand Down Expand Up @@ -290,6 +287,9 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
}
return trustedPublicKeyCount > 0;
}

default:
return NO;
}

return NO;
Expand Down
2 changes: 1 addition & 1 deletion AFNetworking/AFURLResponseSerialization.m
Expand Up @@ -114,7 +114,7 @@ - (BOOL)validateResponse:(NSHTTPURLResponse *)response
BOOL responseIsValid = YES;
NSError *validationError = nil;

if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
!([response MIMEType] == nil && [data length] == 0)) {

Expand Down
4 changes: 2 additions & 2 deletions AFNetworking/AFURLSessionManager.m
Expand Up @@ -1094,9 +1094,9 @@ - (void)URLSession:(NSURLSession *)session
{

int64_t totalUnitCount = totalBytesExpectedToSend;
if(totalUnitCount == NSURLSessionTransferSizeUnknown) {
if (totalUnitCount == NSURLSessionTransferSizeUnknown) {
NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"];
if(contentLength) {
if (contentLength) {
totalUnitCount = (int64_t) [contentLength longLongValue];
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Tests/Resources/HTTPBin.org/httpbinorg_10102018.cer
Binary file not shown.
2 changes: 1 addition & 1 deletion Tests/Tests/AFAutoPurgingImageCacheTests.m
Expand Up @@ -219,7 +219,7 @@ - (void)testThatPrioritizedImagesWithOldestLastAccessDatesAreRemovedDuringPurge
UInt64 postPurgeMemoryUsage = self.cache.memoryUsage;
XCTAssertTrue(postPurgeMemoryUsage < prePurgeMemoryUsage);

for (NSUInteger index = 0; index <= numberOfImages ; index++) {
for (NSUInteger index = 0; index <= numberOfImages; index++) {
NSString * identifier = [NSString stringWithFormat:@"image-%ld",(long)index];
UIImage *cachedImage = [self.cache imageWithIdentifier:identifier];
if (index == 0 || index >= 6) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tests/AFImageDownloaderTests.m
Expand Up @@ -561,7 +561,7 @@ - (void)testThatReceiptIDMatchesReturnedID {

@implementation MockAFAutoPurgingImageCache

-(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
if (self.shouldCache) {
return self.shouldCache(image, request, identifier);
}
Expand All @@ -570,7 +570,7 @@ -(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request with
}
}

-(void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{
- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{
[super addImage:image withIdentifier:identifier];
if (self.addCache) {
self.addCache(image, identifier);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Tests/AFSecurityPolicyTests.m
Expand Up @@ -58,7 +58,7 @@ static SecTrustRef AFUTADNNetServerTrust() {
}

static SecCertificateRef AFUTHTTPBinOrgCertificate() {
NSString *certPath = [[NSBundle bundleForClass:[AFSecurityPolicyTests class]] pathForResource:@"httpbinorg_10102018" ofType:@"cer"];
NSString *certPath = [[NSBundle bundleForClass:[AFSecurityPolicyTests class]] pathForResource:@"httpbinorg_04082019" ofType:@"cer"];
NSCAssert(certPath != nil, @"Path for certificate should not be nil");
NSData *certData = [NSData dataWithContentsOfFile:certPath];

Expand Down
2 changes: 1 addition & 1 deletion UIKit+AFNetworking/AFAutoPurgingImageCache.m
Expand Up @@ -134,7 +134,7 @@ - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier {
[self.cachedImages removeObjectForKey:cachedImage.identifier];
bytesPurged += cachedImage.totalBytes;
if (bytesPurged >= bytesToPurge) {
break ;
break;
}
}
self.currentMemoryUsage -= bytesPurged;
Expand Down
4 changes: 2 additions & 2 deletions UIKit+AFNetworking/UIButton+AFNetworking.m
Expand Up @@ -168,7 +168,7 @@ - (void)setImageForState:(UIControlState)state
if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
if (success) {
success(request, response, responseObject);
} else if(responseObject) {
} else if (responseObject) {
[strongSelf setImage:responseObject forState:state];
}
[strongSelf af_setImageDownloadReceipt:nil forState:state];
Expand Down Expand Up @@ -247,7 +247,7 @@ - (void)setBackgroundImageForState:(UIControlState)state
if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
if (success) {
success(request, response, responseObject);
} else if(responseObject) {
} else if (responseObject) {
[strongSelf setBackgroundImage:responseObject forState:state];
}
[strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
Expand Down
5 changes: 2 additions & 3 deletions UIKit+AFNetworking/UIImageView+AFNetworking.m
Expand Up @@ -75,7 +75,6 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
{

if ([urlRequest URL] == nil) {
self.image = placeholderImage;
if (failure) {
Expand All @@ -85,7 +84,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
return;
}

if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
if ([self isActiveTaskURLEqualToURLRequest:urlRequest]) {
return;
}

Expand Down Expand Up @@ -119,7 +118,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
if (success) {
success(request, response, responseObject);
} else if(responseObject) {
} else if (responseObject) {
strongSelf.image = responseObject;
}
[strongSelf clearActiveDownloadInformation];
Expand Down

0 comments on commit 73ef609

Please sign in to comment.