Skip to content

Commit

Permalink
More networking fixes: 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Seifert committed Feb 27, 2014
1 parent 4744785 commit c33a5ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion QuickHAC/QuickHAC/QuickHAC-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2130</string>
<string>2138</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIBackgroundModes</key>
Expand Down
38 changes: 22 additions & 16 deletions QuickHAC/QuickHAC/SQUDistrictManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions QuickHAC/QuickHAC/SQUSettingsGeneralController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"];
Expand All @@ -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];

Expand Down
Binary file modified QuickHAC/QuickHAC/en.lproj/Localizable.strings
Binary file not shown.

0 comments on commit c33a5ba

Please sign in to comment.