From 92e7b9a652b0d1806d732079574aea7270b8a2c0 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 13 Sep 2010 22:26:54 +0000 Subject: - Implement support for MySQL over SSL for both TCP/IP and Socket connection modes. - Upgrade the MySQL binaries to version 5.1.50 (was 5.1.46) - Enable SSL support in the MySQL libraries (this leads to a large increase in library size, unfortunately) - Enable more optimisations in the MySQL libraries (especially --enable-assembler for faster in-library string processing and --with-mysqld-ldflags=-all-static) This completes support for Issue #27. --- Source/SPPreferenceController.m | 118 +++++++++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 25 deletions(-) (limited to 'Source/SPPreferenceController.m') diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index c1f3877a..d05868b9 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -409,8 +409,8 @@ NSNumber *favoriteid = [NSNumber numberWithInteger:[[NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]] hash]]; // Create default favorite - NSMutableDictionary *favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Favorite", [NSNumber numberWithInteger:0], @"", @"", @"", @"", @"", @"", @"", [NSNumber numberWithInt:NSOffState], @"", @"", favoriteid, nil] - forKeys:[NSArray arrayWithObjects:@"name", @"type", @"host", @"socket", @"user", @"port", @"database", @"sshHost", @"sshUser", @"sshKeyLocationEnabled", @"sshKeyLocation", @"sshPort", @"id", nil]]; + NSMutableDictionary *favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Favorite", [NSNumber numberWithInteger:0], @"", @"", @"", @"", [NSNumber numberWithInt:NSOffState], [NSNumber numberWithInt:NSOffState], [NSNumber numberWithInt:NSOffState], [NSNumber numberWithInt:NSOffState], @"", @"", @"", [NSNumber numberWithInt:NSOffState], @"", @"", favoriteid, nil] + forKeys:[NSArray arrayWithObjects:@"name", @"type", @"host", @"socket", @"user", @"port", @"useSSL", @"sslKeyFileLocationEnabled", @"sslCertificateFileLocationEnabled", @"sslCACertFileLocationEnabled", @"database", @"sshHost", @"sshUser", @"sshKeyLocationEnabled", @"sshKeyLocation", @"sshPort", @"id", nil]]; [favoritesController addObject:favorite]; [favoritesController setSelectedObjects:[NSArray arrayWithObject:favorite]]; @@ -686,47 +686,115 @@ } /** - * Opens the SSH key selection window, ready to select a SSH key. + * Opens the SSH/SSL key selection window, ready to select a key file. */ -- (IBAction)chooseSSHKey:(id)sender + - (IBAction)chooseKeyLocation:(id)sender { NSString *directoryPath = nil; NSString *filePath = nil; + NSArray *permittedFileTypes = nil; + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; - // If the custom key location is currently disabled - after the button - // action - leave it disabled and return without showing the sheet. - if (![[favoritesController valueForKeyPath:@"selection.sshKeyLocationEnabled"] intValue]) { - return; - } + // Switch details by sender. + // First, SSH keys: + if (sender == sshSSHKeyButton) { - // Otherwise open a panel at the last or default location - if ([favoritesController valueForKeyPath:@"selection.sshKeyLocation"] && [[favoritesController valueForKeyPath:@"selection.sshKeyLocation"] length]) { - filePath = [[favoritesController valueForKeyPath:@"selection.sshKeyLocation"] lastPathComponent]; - directoryPath = [[favoritesController valueForKeyPath:@"selection.sshKeyLocation"] stringByDeletingLastPathComponent]; - } + // If the custom key location is currently disabled - after the button + // action - leave it disabled and return without showing the sheet. + if (![favoritesController valueForKeyPath:@"selection.sshKeyLocationEnabled"]) { + return; + } + // Otherwise open a panel at the last or default location + NSString *sshKeyLocation = [favoritesController valueForKeyPath:@"selection.sshKeyLocation"]; + if (sshKeyLocation && [sshKeyLocation length]) { + filePath = [sshKeyLocation lastPathComponent]; + directoryPath = [sshKeyLocation stringByDeletingLastPathComponent]; + } + + permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"", nil]; + [openPanel setAccessoryView:sshKeyLocationHelp]; + + // SSL key file location: + } else if (sender == standardSSLKeyFileButton || sender == socketSSLKeyFileButton) { + if ([sender state] == NSOffState) { + [favoritesController setValue:nil forKeyPath:@"selection.sslKeyFileLocation"]; + return; + } + permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"key", @"", nil]; + [openPanel setAccessoryView:sslKeyFileLocationHelp]; + + // SSL certificate file location: + } else if (sender == standardSSLCertificateButton || sender == socketSSLCertificateButton) { + if ([sender state] == NSOffState) { + [favoritesController setValue:nil forKeyPath:@"selection.sslCertificateFileLocation"]; + return; + } + permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"", nil]; + [openPanel setAccessoryView:sslCertificateLocationHelp]; + + // SSL CA certificate file location: + } else if (sender == standardSSLCACertButton || sender == socketSSLCACertButton) { + if ([sender state] == NSOffState) { + [favoritesController setValue:nil forKeyPath:@"selection.sslCACertFileLocation"]; + return; + } + permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"", nil]; + [openPanel setAccessoryView:sslCACertLocationHelp]; + } - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; - [openPanel setAccessoryView:sshKeyLocationHelp]; [openPanel beginSheetForDirectory:directoryPath file:filePath - types:[NSArray arrayWithObjects:@"pem", @"", nil] + types:permittedFileTypes modalForWindow:preferencesWindow modalDelegate:self - didEndSelector:@selector(chooseSSHKeySheetDidEnd:returnCode:contextInfo:) - contextInfo:nil]; + didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) + contextInfo:sender]; } /** - * Called after closing the SSH key selection sheet. + * Called after closing the SSH/SSL key selection sheet. */ -- (void)chooseSSHKeySheetDidEnd:(NSOpenPanel *)openPanel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +- (void)chooseKeyLocationSheetDidEnd:(NSOpenPanel *)openPanel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { - if (returnCode == NSCancelButton) { - [favoritesController setValue:[NSNumber numberWithInt:NSOffState] forKeyPath:@"selection.sshKeyLocationEnabled"]; - return; + NSString *abbreviatedFileName = [[openPanel filename] stringByAbbreviatingWithTildeInPath]; + + // SSH key file selection + if (contextInfo == sshSSHKeyButton) { + if (returnCode == NSCancelButton) { + [favoritesController setValue:[NSNumber numberWithInt:NSOffState] forKeyPath:@"selection.sshKeyLocationEnabled"]; + return; + } + [favoritesController setValue:abbreviatedFileName forKeyPath:@"selection.sshKeyLocation"]; + [self setSshKeyLocation:abbreviatedFileName]; + + // SSL key file selection + } else if (contextInfo == standardSSLKeyFileButton || contextInfo == socketSSLKeyFileButton) { + if (returnCode == NSCancelButton) { + [favoritesController setValue:[NSNumber numberWithInt:NSOffState] forKeyPath:@"selection.sslKeyFileLocationEnabled"]; + [favoritesController setValue:nil forKeyPath:@"selection.sslKeyFileLocation"]; + return; + } + [favoritesController setValue:abbreviatedFileName forKeyPath:@"selection.sslKeyFileLocation"]; + + // SSL certificate file selection + } else if (contextInfo == standardSSLCertificateButton || contextInfo == socketSSLCertificateButton) { + if (returnCode == NSCancelButton) { + [favoritesController setValue:[NSNumber numberWithInt:NSOffState] forKeyPath:@"selection.sslCertificateFileLocationEnabled"]; + [favoritesController setValue:nil forKeyPath:@"selection.sslCertificateFileLocation"]; + return; + } + [favoritesController setValue:abbreviatedFileName forKeyPath:@"selection.sslCertificateFileLocation"]; + + // SSL CA certificate file selection + } else if (contextInfo == standardSSLCACertButton || contextInfo == socketSSLCACertButton) { + if (returnCode == NSCancelButton) { + [favoritesController setValue:[NSNumber numberWithInt:NSOffState] forKeyPath:@"selection.sslCACertFileLocationEnabled"]; + [favoritesController setValue:nil forKeyPath:@"selection.sslCACertFileLocation"]; + return; + } + [favoritesController setValue:abbreviatedFileName forKeyPath:@"selection.sslCACertFileLocation"]; } - [favoritesController setValue:[[openPanel filename] stringByAbbreviatingWithTildeInPath] forKeyPath:@"selection.sshKeyLocation"]; } #pragma mark - -- cgit v1.2.3