From c33a5ba707bb46a7689cf7c64efe9c5a774c0bd4 Mon Sep 17 00:00:00 2001 From: Tristan Seifert Date: Wed, 26 Feb 2014 18:09:31 -0600 Subject: [PATCH] More networking fixes: 1.0.2 --- QuickHAC/QuickHAC/QuickHAC-Info.plist | 2 +- QuickHAC/QuickHAC/SQUDistrictManager.m | 38 ++++++++++-------- .../QuickHAC/SQUSettingsGeneralController.m | 11 ++--- .../QuickHAC/en.lproj/Localizable.strings | Bin 21256 -> 21534 bytes 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/QuickHAC/QuickHAC/QuickHAC-Info.plist b/QuickHAC/QuickHAC/QuickHAC-Info.plist index ec07024..b1072da 100644 --- a/QuickHAC/QuickHAC/QuickHAC-Info.plist +++ b/QuickHAC/QuickHAC/QuickHAC-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 2130 + 2138 LSRequiresIPhoneOS UIBackgroundModes diff --git a/QuickHAC/QuickHAC/SQUDistrictManager.m b/QuickHAC/QuickHAC/SQUDistrictManager.m index b6588f1..382ddae 100644 --- a/QuickHAC/QuickHAC/SQUDistrictManager.m +++ b/QuickHAC/QuickHAC/SQUDistrictManager.m @@ -119,23 +119,29 @@ - (BOOL) selectDistrictWithID:(NSInteger) districtID { - (void) setCurrentDistrict:(SQUDistrict *) currentDistrict { _currentDistrict = currentDistrict; - // Load the district's SSL certs, if they are specified. - NSArray *certs = [currentDistrict districtSSLCertData]; - - // If there's no certs, panic - if((certs.count == 1 && [certs[0] integerValue] == 0) || !certs) { - _HTTPManager.securityPolicy.SSLPinningMode = AFSSLPinningModeNone; - _HTTPManager.securityPolicy.allowInvalidCertificates = YES; - _HTTPManager.securityPolicy.pinnedCertificates = nil; - - // NSLog(@"SECURITY POLICY CHANGED: Accepts invalid certs (%@)", currentDistrict.name); - } else if(certs.count != 0) { - _HTTPManager.securityPolicy.allowInvalidCertificates = NO; - _HTTPManager.securityPolicy.SSLPinningMode = AFSSLPinningModeCertificate; + // Check if the user disabled certificate validation + if([[NSUserDefaults standardUserDefaults] boolForKey:@"certPinning"]) { + // Load the district's SSL certs, if they are specified. + NSArray *certs = [currentDistrict districtSSLCertData]; - [_HTTPManager.securityPolicy setPinnedCertificates:certs]; - - // NSLog(@"SECURITY POLICY CHANGED: Rejects invalid certs (%@)", currentDistrict.name); + // If there's no certs, panic + if((certs.count == 1 && [certs[0] integerValue] == 0) || !certs) { + _HTTPManager.securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + _HTTPManager.securityPolicy.allowInvalidCertificates = YES; + _HTTPManager.securityPolicy.pinnedCertificates = nil; + + // NSLog(@"SECURITY POLICY CHANGED: Accepts invalid certs (%@)", currentDistrict.name); + } else if(certs.count != 0) { + _HTTPManager.securityPolicy.allowInvalidCertificates = NO; + _HTTPManager.securityPolicy.SSLPinningMode = AFSSLPinningModeCertificate; + + [_HTTPManager.securityPolicy setPinnedCertificates:certs]; + + // NSLog(@"SECURITY POLICY CHANGED: Rejects invalid certs (%@)", currentDistrict.name); + } + } else { + _HTTPManager.securityPolicy.allowInvalidCertificates = YES; + NSLog(@"WARNING: Accepting any certificate!"); } // Clear munchies so we're logged out (prevents course mingling) diff --git a/QuickHAC/QuickHAC/SQUSettingsGeneralController.m b/QuickHAC/QuickHAC/SQUSettingsGeneralController.m index 6b86c78..5dfe3b5 100644 --- a/QuickHAC/QuickHAC/SQUSettingsGeneralController.m +++ b/QuickHAC/QuickHAC/SQUSettingsGeneralController.m @@ -51,14 +51,14 @@ - (id) init { }; [section addElement:button]; - section.footer =NSLocalizedString(@"Calculated GPA may not be accurate. We are not responsible for any problems arising from inaccurate calculations.", nil); + section.footer =NSLocalizedString(@"Calculated GPA may not be accurate. We are not responsible for any problems arising from inaccurate calculations.", @"general settings"); [root addSection:section]; // Build "Appearance" section - section = [[QSection alloc] initWithTitle:NSLocalizedString(@"Grade Colourisation", nil)]; + section = [[QSection alloc] initWithTitle:NSLocalizedString(@"Grade Colourisation", @"general settings")]; - QFloatElement *asianness = [[QFloatElement alloc] initWithTitle:NSLocalizedString(@"Power Level", nil) value:[[NSUserDefaults standardUserDefaults] floatForKey:@"asianness"]]; + QFloatElement *asianness = [[QFloatElement alloc] initWithTitle:NSLocalizedString(@"Power Level", @"general settings") value:[[NSUserDefaults standardUserDefaults] floatForKey:@"asianness"]]; __unsafe_unretained QFloatElement *tempAsianness = asianness; asianness.minimumValue = 1.0; asianness.maximumValue = 12.2; @@ -67,7 +67,7 @@ - (id) init { }; [section addElement:asianness]; - SQUSettingsHueElement *hue = [[SQUSettingsHueElement alloc] initWithTitle:NSLocalizedString(@"Hue", nil) value:[[NSUserDefaults standardUserDefaults] floatForKey:@"gradesHue"]]; + SQUSettingsHueElement *hue = [[SQUSettingsHueElement alloc] initWithTitle:NSLocalizedString(@"Hue", @"general settings") value:[[NSUserDefaults standardUserDefaults] floatForKey:@"gradesHue"]]; __unsafe_unretained SQUSettingsHueElement *tempHue = hue; hue.onValueChanged = ^(QRootElement *element) { [[NSUserDefaults standardUserDefaults] setFloat:tempHue.floatValue forKey:@"gradesHue"]; @@ -79,13 +79,14 @@ - (id) init { // Misc section section = [[QSection alloc] initWithTitle:NSLocalizedString(@"Miscellaneous", nil)]; - QBooleanElement *secureSwitcher = [[QBooleanElement alloc] initWithTitle:NSLocalizedString(@"Validate Certificates", nil) BoolValue:[[NSUserDefaults standardUserDefaults] boolForKey:@"certPinning"]]; + QBooleanElement *secureSwitcher = [[QBooleanElement alloc] initWithTitle:NSLocalizedString(@"Connection Validation", @"general settings") BoolValue:[[NSUserDefaults standardUserDefaults] boolForKey:@"certPinning"]]; __unsafe_unretained QBooleanElement *secureSwitcherTmp = secureSwitcher; secureSwitcher.onValueChanged = ^(QRootElement *element) { [[NSUserDefaults standardUserDefaults] setBool:secureSwitcherTmp.boolValue forKey:@"certPinning"]; }; [section addElement:secureSwitcher]; + section.footer = NSLocalizedString(@"If you have difficulty getting grades, try disabling this option.", @"general settings"); [root addSection:section]; diff --git a/QuickHAC/QuickHAC/en.lproj/Localizable.strings b/QuickHAC/QuickHAC/en.lproj/Localizable.strings index dfacc046a9da8c28de013a6b3619a0fea57c4ff3..ab166162dd2efaa1ab10aba0e7c070e0fd2aef42 100644 GIT binary patch delta 264 zcmeBJ#yD>U;|7jkRwV{chP282&Z6}x44DjRK$yvp%uvdZ!%)Id$)LcH&X5XZl>kNa zfNT)Ih#`?71t?m~pabNW0Qn$wAl=14nIxc2nA#GC46vvILq00K=9tvj6}9 delta 9 QcmbQYg0W*6;|7jk029Llf&c&j