diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index c3638d97..95be679f 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -109,27 +109,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults host = [[SUHost alloc] initWithBundle:bundle]; // Saving-the-developer-from-a-stupid-mistake-check: - BOOL hasPublicDSAKey = [host publicDSAKey] != nil; - BOOL isMainBundle = [bundle isEqualTo:[NSBundle mainBundle]]; - BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned]; - BOOL servingOverHttps = [[[[self feedURL] scheme] lowercaseString] isEqualToString:@"https"]; - if (!isMainBundle && !hasPublicDSAKey) { - [self notifyWillShowModalAlert]; - NSAlert *alert = [[NSAlert alloc] init]; - alert.messageText = @"Insecure update error!"; - alert.informativeText = @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information."; - [alert runModal]; - [self notifyDidShowModalAlert]; - } else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) { - [self notifyWillShowModalAlert]; - NSAlert *alert = [[NSAlert alloc] init]; - alert.messageText = @"Insecure update error!"; - alert.informativeText = @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information."; - [alert runModal]; - [self notifyDidShowModalAlert]; - } else if (isMainBundle && !hasPublicDSAKey && !servingOverHttps) { - SULog(@"WARNING: Serving updates over http without signing them with a DSA key is deprecated and may not be possible in a future release. Please serve your updates over https, or sign them with a DSA key, or do both. See Sparkle's documentation for more information."); - } + [self checkIfConfiguredProperly]; + // This runs the permission prompt if needed, but never before the app has finished launching because the runloop won't run before that [self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:0]; @@ -137,6 +118,43 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults return self; } +-(void)showModalAlertText:(NSString *)text informativeText:(NSString *)informativeText { + [self notifyWillShowModalAlert]; + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = text; + alert.informativeText = informativeText; + [alert runModal]; + [self notifyDidShowModalAlert]; +} + +-(void)checkIfConfiguredProperly { + BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil; + BOOL isMainBundle = [self.host.bundle isEqualTo:[NSBundle mainBundle]]; + BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned]; + NSURL *feedURL = [self feedURL]; + BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"]; + if (!isMainBundle && !hasPublicDSAKey) { + [self showModalAlertText:@"Insecure update error!" + informativeText:@"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information."]; + } else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) { + [self showModalAlertText:@"Insecure update error!" + informativeText:@"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information."]; + } else if (isMainBundle && !hasPublicDSAKey && !servingOverHttps) { + SULog(@"WARNING: Serving updates over HTTP without signing them with a DSA key is deprecated and may not be possible in a future release. Please serve your updates over https, or sign them with a DSA key, or do both. See Sparkle's documentation for more information."); + } + +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 + BOOL atsExceptionsExist = nil != [self.host objectForInfoDictionaryKey:@"NSAppTransportSecurity"]; + if (isMainBundle && !servingOverHttps && !atsExceptionsExist) { + [self showModalAlertText:@"Insecure feed URL is blocked in OS X 10.11" + informativeText:[NSString stringWithFormat:@"You must change the feed URL (%@) to use HTTPS or disable App Transport Security.\n\nFor more information:\nhttp://sparkle-project.org/documentation/app-transport-security/", [feedURL absoluteString]]]; + } + if (!isMainBundle && !servingOverHttps) { + SULog(@"WARNING: Serving updates over HTTP may be blocked in OS X 10.11. Please change the feed URL (%@) to use HTTPS. For more information:\nhttp://sparkle-project.org/documentation/app-transport-security/", feedURL); + } +#endif +} + // This will be used when the updater is instantiated in a nib such as MainMenu - (instancetype)init