mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Introduce SSL support on session manager. Code parts from SuperNiFF. Fixes issue #518.
This commit is contained in:
@ -4,10 +4,10 @@ object connform: Tconnform
|
|||||||
Top = 129
|
Top = 129
|
||||||
BorderIcons = [biSystemMenu]
|
BorderIcons = [biSystemMenu]
|
||||||
Caption = 'Session manager'
|
Caption = 'Session manager'
|
||||||
ClientHeight = 303
|
ClientHeight = 378
|
||||||
ClientWidth = 494
|
ClientWidth = 494
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
Constraints.MinHeight = 310
|
Constraints.MinHeight = 360
|
||||||
Constraints.MinWidth = 510
|
Constraints.MinWidth = 510
|
||||||
Font.Charset = DEFAULT_CHARSET
|
Font.Charset = DEFAULT_CHARSET
|
||||||
Font.Color = clWindowText
|
Font.Color = clWindowText
|
||||||
@ -25,7 +25,7 @@ object connform: Tconnform
|
|||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
DesignSize = (
|
DesignSize = (
|
||||||
494
|
494
|
||||||
303)
|
378)
|
||||||
PixelsPerInch = 96
|
PixelsPerInch = 96
|
||||||
TextHeight = 13
|
TextHeight = 13
|
||||||
object lblSession: TLabel
|
object lblSession: TLabel
|
||||||
@ -49,7 +49,7 @@ object connform: Tconnform
|
|||||||
end
|
end
|
||||||
object btnSave: TButton
|
object btnSave: TButton
|
||||||
Left = 64
|
Left = 64
|
||||||
Top = 270
|
Top = 345
|
||||||
Width = 50
|
Width = 50
|
||||||
Height = 25
|
Height = 25
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
@ -60,7 +60,7 @@ object connform: Tconnform
|
|||||||
object btnOpen: TButton
|
object btnOpen: TButton
|
||||||
Tag = 15
|
Tag = 15
|
||||||
Left = 320
|
Left = 320
|
||||||
Top = 270
|
Top = 345
|
||||||
Width = 80
|
Width = 80
|
||||||
Height = 25
|
Height = 25
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
@ -73,7 +73,7 @@ object connform: Tconnform
|
|||||||
object btnCancel: TButton
|
object btnCancel: TButton
|
||||||
Tag = 16
|
Tag = 16
|
||||||
Left = 406
|
Left = 406
|
||||||
Top = 270
|
Top = 345
|
||||||
Width = 80
|
Width = 80
|
||||||
Height = 25
|
Height = 25
|
||||||
Anchors = [akRight, akBottom]
|
Anchors = [akRight, akBottom]
|
||||||
@ -86,7 +86,7 @@ object connform: Tconnform
|
|||||||
Left = 9
|
Left = 9
|
||||||
Top = 27
|
Top = 27
|
||||||
Width = 162
|
Width = 162
|
||||||
Height = 235
|
Height = 310
|
||||||
Anchors = [akLeft, akTop, akBottom]
|
Anchors = [akLeft, akTop, akBottom]
|
||||||
EditDelay = 250
|
EditDelay = 250
|
||||||
Header.AutoSizeIndex = 0
|
Header.AutoSizeIndex = 0
|
||||||
@ -121,7 +121,7 @@ object connform: Tconnform
|
|||||||
end
|
end
|
||||||
object btnNew: TButton
|
object btnNew: TButton
|
||||||
Left = 8
|
Left = 8
|
||||||
Top = 270
|
Top = 345
|
||||||
Width = 50
|
Width = 50
|
||||||
Height = 25
|
Height = 25
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
@ -131,7 +131,7 @@ object connform: Tconnform
|
|||||||
end
|
end
|
||||||
object btnDelete: TButton
|
object btnDelete: TButton
|
||||||
Left = 120
|
Left = 120
|
||||||
Top = 270
|
Top = 345
|
||||||
Width = 50
|
Width = 50
|
||||||
Height = 25
|
Height = 25
|
||||||
Anchors = [akLeft, akBottom]
|
Anchors = [akLeft, akBottom]
|
||||||
@ -143,14 +143,14 @@ object connform: Tconnform
|
|||||||
Left = 177
|
Left = 177
|
||||||
Top = 10
|
Top = 10
|
||||||
Width = 309
|
Width = 309
|
||||||
Height = 254
|
Height = 329
|
||||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||||
Caption = 'Details'
|
Caption = 'Details'
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
Visible = False
|
Visible = False
|
||||||
DesignSize = (
|
DesignSize = (
|
||||||
309
|
309
|
||||||
254)
|
329)
|
||||||
object lblHost: TLabel
|
object lblHost: TLabel
|
||||||
Tag = 6
|
Tag = 6
|
||||||
Left = 8
|
Left = 8
|
||||||
@ -189,28 +189,28 @@ object connform: Tconnform
|
|||||||
end
|
end
|
||||||
object lblLastConnectLeft: TLabel
|
object lblLastConnectLeft: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Top = 191
|
Top = 271
|
||||||
Width = 65
|
Width = 65
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'Last connect:'
|
Caption = 'Last connect:'
|
||||||
end
|
end
|
||||||
object lblLastConnectRight: TLabel
|
object lblLastConnectRight: TLabel
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 191
|
Top = 271
|
||||||
Width = 5
|
Width = 5
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = '?'
|
Caption = '?'
|
||||||
end
|
end
|
||||||
object lblCreatedLeft: TLabel
|
object lblCreatedLeft: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Top = 227
|
Top = 307
|
||||||
Width = 43
|
Width = 43
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'Created:'
|
Caption = 'Created:'
|
||||||
end
|
end
|
||||||
object lblCreatedRight: TLabel
|
object lblCreatedRight: TLabel
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 227
|
Top = 307
|
||||||
Width = 5
|
Width = 5
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = '?'
|
Caption = '?'
|
||||||
@ -224,48 +224,75 @@ object connform: Tconnform
|
|||||||
end
|
end
|
||||||
object lblCounterLeft: TLabel
|
object lblCounterLeft: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Top = 209
|
Top = 289
|
||||||
Width = 43
|
Width = 43
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'Counter:'
|
Caption = 'Counter:'
|
||||||
end
|
end
|
||||||
object lblCounterRight: TLabel
|
object lblCounterRight: TLabel
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 209
|
Top = 289
|
||||||
Width = 5
|
Width = 5
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = '?'
|
Caption = '?'
|
||||||
end
|
end
|
||||||
object lblStartupScript: TLabel
|
object lblStartupScript: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Top = 168
|
Top = 243
|
||||||
Width = 69
|
Width = 69
|
||||||
Height = 13
|
Height = 13
|
||||||
Caption = 'Startup script:'
|
Caption = 'Startup script:'
|
||||||
FocusControl = editStartupScript
|
FocusControl = editStartupScript
|
||||||
end
|
end
|
||||||
|
object lblSSLPrivateKey: TLabel
|
||||||
|
Tag = 6
|
||||||
|
Left = 8
|
||||||
|
Top = 168
|
||||||
|
Width = 78
|
||||||
|
Height = 13
|
||||||
|
Caption = 'SSL private key:'
|
||||||
|
FocusControl = editSSLPrivateKey
|
||||||
|
end
|
||||||
|
object lblSSLCACertificate: TLabel
|
||||||
|
Tag = 6
|
||||||
|
Left = 8
|
||||||
|
Top = 193
|
||||||
|
Width = 89
|
||||||
|
Height = 13
|
||||||
|
Caption = 'SSL CA certificate:'
|
||||||
|
FocusControl = editSSLCACertificate
|
||||||
|
end
|
||||||
|
object lblSSLCertificate: TLabel
|
||||||
|
Tag = 6
|
||||||
|
Left = 8
|
||||||
|
Top = 218
|
||||||
|
Width = 72
|
||||||
|
Height = 13
|
||||||
|
Caption = 'SSL certificate:'
|
||||||
|
FocusControl = editSSLCertificate
|
||||||
|
end
|
||||||
object editHost: TEdit
|
object editHost: TEdit
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 42
|
Top = 42
|
||||||
Width = 205
|
Width = 194
|
||||||
Height = 21
|
Height = 21
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnChange = Modification
|
OnChange = Modification
|
||||||
end
|
end
|
||||||
object editUsername: TEdit
|
object editUsername: TEdit
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 67
|
Top = 67
|
||||||
Width = 205
|
Width = 194
|
||||||
Height = 21
|
Height = 21
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
OnChange = Modification
|
OnChange = Modification
|
||||||
end
|
end
|
||||||
object editPassword: TEdit
|
object editPassword: TEdit
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 92
|
Top = 92
|
||||||
Width = 205
|
Width = 194
|
||||||
Height = 21
|
Height = 21
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
PasswordChar = '*'
|
PasswordChar = '*'
|
||||||
@ -273,7 +300,7 @@ object connform: Tconnform
|
|||||||
OnChange = Modification
|
OnChange = Modification
|
||||||
end
|
end
|
||||||
object editPort: TEdit
|
object editPort: TEdit
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 117
|
Top = 117
|
||||||
Width = 60
|
Width = 60
|
||||||
Height = 21
|
Height = 21
|
||||||
@ -283,9 +310,9 @@ object connform: Tconnform
|
|||||||
end
|
end
|
||||||
object chkCompressed: TCheckBox
|
object chkCompressed: TCheckBox
|
||||||
Tag = 12
|
Tag = 12
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 142
|
Top = 142
|
||||||
Width = 205
|
Width = 194
|
||||||
Height = 17
|
Height = 17
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
Caption = 'Compressed client/server protocol'
|
Caption = 'Compressed client/server protocol'
|
||||||
@ -293,7 +320,7 @@ object connform: Tconnform
|
|||||||
OnClick = Modification
|
OnClick = Modification
|
||||||
end
|
end
|
||||||
object radioTypeTCPIP: TRadioButton
|
object radioTypeTCPIP: TRadioButton
|
||||||
Left = 99
|
Left = 110
|
||||||
Top = 19
|
Top = 19
|
||||||
Width = 67
|
Width = 67
|
||||||
Height = 17
|
Height = 17
|
||||||
@ -304,7 +331,7 @@ object connform: Tconnform
|
|||||||
OnClick = radioNetTypeClick
|
OnClick = radioNetTypeClick
|
||||||
end
|
end
|
||||||
object radioTypeNamedPipe: TRadioButton
|
object radioTypeNamedPipe: TRadioButton
|
||||||
Left = 172
|
Left = 183
|
||||||
Top = 19
|
Top = 19
|
||||||
Width = 113
|
Width = 113
|
||||||
Height = 17
|
Height = 17
|
||||||
@ -313,7 +340,7 @@ object connform: Tconnform
|
|||||||
OnClick = radioNetTypeClick
|
OnClick = radioNetTypeClick
|
||||||
end
|
end
|
||||||
object updownPort: TUpDown
|
object updownPort: TUpDown
|
||||||
Left = 159
|
Left = 170
|
||||||
Top = 117
|
Top = 117
|
||||||
Width = 17
|
Width = 17
|
||||||
Height = 21
|
Height = 21
|
||||||
@ -323,25 +350,66 @@ object connform: Tconnform
|
|||||||
OnChangingEx = updownPortChangingEx
|
OnChangingEx = updownPortChangingEx
|
||||||
end
|
end
|
||||||
object editStartupScript: TButtonedEdit
|
object editStartupScript: TButtonedEdit
|
||||||
Left = 99
|
Left = 110
|
||||||
|
Top = 240
|
||||||
|
Width = 194
|
||||||
|
Height = 21
|
||||||
|
Anchors = [akLeft, akTop, akRight]
|
||||||
|
Images = MainForm.ImageListMain
|
||||||
|
RightButton.ImageIndex = 52
|
||||||
|
RightButton.Visible = True
|
||||||
|
TabOrder = 11
|
||||||
|
OnChange = Modification
|
||||||
|
OnDblClick = PickFile
|
||||||
|
OnRightButtonClick = PickFile
|
||||||
|
end
|
||||||
|
object editSSLPrivateKey: TButtonedEdit
|
||||||
|
Left = 110
|
||||||
Top = 165
|
Top = 165
|
||||||
Width = 205
|
Width = 194
|
||||||
Height = 21
|
Height = 21
|
||||||
Anchors = [akLeft, akTop, akRight]
|
Anchors = [akLeft, akTop, akRight]
|
||||||
Images = MainForm.ImageListMain
|
Images = MainForm.ImageListMain
|
||||||
RightButton.ImageIndex = 52
|
RightButton.ImageIndex = 52
|
||||||
RightButton.Visible = True
|
RightButton.Visible = True
|
||||||
TabOrder = 8
|
TabOrder = 8
|
||||||
TextHint = 'Select SQL file ...'
|
|
||||||
OnChange = Modification
|
OnChange = Modification
|
||||||
OnDblClick = editStartupScriptRightButtonClick
|
OnDblClick = PickFile
|
||||||
OnRightButtonClick = editStartupScriptRightButtonClick
|
OnRightButtonClick = PickFile
|
||||||
|
end
|
||||||
|
object editSSLCACertificate: TButtonedEdit
|
||||||
|
Left = 110
|
||||||
|
Top = 190
|
||||||
|
Width = 194
|
||||||
|
Height = 21
|
||||||
|
Anchors = [akLeft, akTop, akRight]
|
||||||
|
Images = MainForm.ImageListMain
|
||||||
|
RightButton.ImageIndex = 52
|
||||||
|
RightButton.Visible = True
|
||||||
|
TabOrder = 9
|
||||||
|
OnChange = Modification
|
||||||
|
OnDblClick = PickFile
|
||||||
|
OnRightButtonClick = PickFile
|
||||||
|
end
|
||||||
|
object editSSLCertificate: TButtonedEdit
|
||||||
|
Left = 110
|
||||||
|
Top = 215
|
||||||
|
Width = 194
|
||||||
|
Height = 21
|
||||||
|
Anchors = [akLeft, akTop, akRight]
|
||||||
|
Images = MainForm.ImageListMain
|
||||||
|
RightButton.ImageIndex = 52
|
||||||
|
RightButton.Visible = True
|
||||||
|
TabOrder = 10
|
||||||
|
OnChange = Modification
|
||||||
|
OnDblClick = PickFile
|
||||||
|
OnRightButtonClick = PickFile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object popupSessions: TPopupMenu
|
object popupSessions: TPopupMenu
|
||||||
Images = MainForm.ImageListMain
|
Images = MainForm.ImageListMain
|
||||||
Left = 176
|
Left = 176
|
||||||
Top = 267
|
Top = 347
|
||||||
object Save1: TMenuItem
|
object Save1: TMenuItem
|
||||||
Caption = 'Save'
|
Caption = 'Save'
|
||||||
ImageIndex = 10
|
ImageIndex = 10
|
||||||
@ -365,6 +433,6 @@ object connform: Tconnform
|
|||||||
Interval = 60000
|
Interval = 60000
|
||||||
OnTimer = TimerStatisticsTimer
|
OnTimer = TimerStatisticsTimer
|
||||||
Left = 208
|
Left = 208
|
||||||
Top = 267
|
Top = 347
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,6 +50,12 @@ type
|
|||||||
lblHelp: TLabel;
|
lblHelp: TLabel;
|
||||||
lblStartupScript: TLabel;
|
lblStartupScript: TLabel;
|
||||||
editStartupScript: TButtonedEdit;
|
editStartupScript: TButtonedEdit;
|
||||||
|
lblSSLPrivateKey: TLabel;
|
||||||
|
editSSLPrivateKey: TButtonedEdit;
|
||||||
|
lblSSLCACertificate: TLabel;
|
||||||
|
editSSLCACertificate: TButtonedEdit;
|
||||||
|
editSSLCertificate: TButtonedEdit;
|
||||||
|
lblSSLCertificate: TLabel;
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure btnOpenClick(Sender: TObject);
|
procedure btnOpenClick(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
@ -81,13 +87,14 @@ type
|
|||||||
Direction: TUpDownDirection);
|
Direction: TUpDownDirection);
|
||||||
procedure editPortChange(Sender: TObject);
|
procedure editPortChange(Sender: TObject);
|
||||||
procedure FormResize(Sender: TObject);
|
procedure FormResize(Sender: TObject);
|
||||||
procedure editStartupScriptRightButtonClick(Sender: TObject);
|
procedure PickFile(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FLoaded: Boolean;
|
FLoaded: Boolean;
|
||||||
FSessionNames: TStringlist;
|
FSessionNames: TStringlist;
|
||||||
FSessionModified, FSessionAdded: Boolean;
|
FSessionModified, FSessionAdded: Boolean;
|
||||||
FOrgNetType: Byte;
|
FOrgNetType: Byte;
|
||||||
|
FOrgSSL_Key, FOrgSSL_Cert, FOrgSSL_CA,
|
||||||
FOrgHost, FOrgUser, FOrgPassword, FOrgStartupScript: String;
|
FOrgHost, FOrgUser, FOrgPassword, FOrgStartupScript: String;
|
||||||
FOrgCompressed: Boolean;
|
FOrgCompressed: Boolean;
|
||||||
FOrgPort: Integer;
|
FOrgPort: Integer;
|
||||||
@ -193,6 +200,9 @@ begin
|
|||||||
Params.Username := editUsername.Text;
|
Params.Username := editUsername.Text;
|
||||||
Params.Password := editPassword.Text;
|
Params.Password := editPassword.Text;
|
||||||
Params.Port := MakeInt(editPort.Text);
|
Params.Port := MakeInt(editPort.Text);
|
||||||
|
Params.SSLPrivateKey := editSSLPrivateKey.Text;
|
||||||
|
Params.SSLCertificate := editSSLCertificate.Text;
|
||||||
|
Params.SSLCACertificate := editSSLCACertificate.Text;
|
||||||
Params.StartupScriptFilename := editStartupScript.Text;
|
Params.StartupScriptFilename := editStartupScript.Text;
|
||||||
if chkCompressed.Checked then
|
if chkCompressed.Checked then
|
||||||
Params.Options := Params.Options + [opCompress]
|
Params.Options := Params.Options + [opCompress]
|
||||||
@ -223,6 +233,9 @@ begin
|
|||||||
MainReg.WriteString(REGNAME_STARTUPSCRIPT, editStartupScript.Text);
|
MainReg.WriteString(REGNAME_STARTUPSCRIPT, editStartupScript.Text);
|
||||||
if IsNew then
|
if IsNew then
|
||||||
MainReg.WriteString(REGNAME_SESSIONCREATED, DateTimeToStr(Now));
|
MainReg.WriteString(REGNAME_SESSIONCREATED, DateTimeToStr(Now));
|
||||||
|
MainReg.WriteString(REGNAME_SSL_KEY, editSSLPrivateKey.Text);
|
||||||
|
MainReg.WriteString(REGNAME_SSL_CERT, editSSLCertificate.Text);
|
||||||
|
MainReg.WriteString(REGNAME_SSL_CA, editSSLCACertificate.Text);
|
||||||
FSessionModified := False;
|
FSessionModified := False;
|
||||||
FSessionAdded := False;
|
FSessionAdded := False;
|
||||||
RefreshSessionList(True);
|
RefreshSessionList(True);
|
||||||
@ -381,6 +394,9 @@ begin
|
|||||||
FOrgPort := StrToIntDef(GetRegValue(REGNAME_PORT, '', SelectedSession), DEFAULT_PORT);
|
FOrgPort := StrToIntDef(GetRegValue(REGNAME_PORT, '', SelectedSession), DEFAULT_PORT);
|
||||||
FOrgCompressed := GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, SelectedSession);
|
FOrgCompressed := GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, SelectedSession);
|
||||||
FOrgStartupScript := GetRegValue(REGNAME_STARTUPSCRIPT, '', SelectedSession);
|
FOrgStartupScript := GetRegValue(REGNAME_STARTUPSCRIPT, '', SelectedSession);
|
||||||
|
FOrgSSL_Key := GetRegValue(REGNAME_SSL_KEY, '', SelectedSession);
|
||||||
|
FOrgSSL_Cert := GetRegValue(REGNAME_SSL_CERT, '', SelectedSession);
|
||||||
|
FOrgSSL_CA := GetRegValue(REGNAME_SSL_CA, '', SelectedSession);
|
||||||
end else begin
|
end else begin
|
||||||
// Editing a new session, not saved yet
|
// Editing a new session, not saved yet
|
||||||
FOrgNetType := NETTYPE_TCPIP;
|
FOrgNetType := NETTYPE_TCPIP;
|
||||||
@ -390,6 +406,9 @@ begin
|
|||||||
FOrgPort := DEFAULT_PORT;
|
FOrgPort := DEFAULT_PORT;
|
||||||
FOrgCompressed := DEFAULT_COMPRESSED;
|
FOrgCompressed := DEFAULT_COMPRESSED;
|
||||||
FOrgStartupScript := DEFAULT_STARTUPSCRIPT;
|
FOrgStartupScript := DEFAULT_STARTUPSCRIPT;
|
||||||
|
FOrgSSL_Key := '';
|
||||||
|
FOrgSSL_Cert := '';
|
||||||
|
FOrgSSL_CA := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FLoaded := False;
|
FLoaded := False;
|
||||||
@ -402,6 +421,9 @@ begin
|
|||||||
editUsername.Text := FOrgUser;
|
editUsername.Text := FOrgUser;
|
||||||
editPassword.Text := FOrgPassword;
|
editPassword.Text := FOrgPassword;
|
||||||
editPort.Text := IntToStr(FOrgPort);
|
editPort.Text := IntToStr(FOrgPort);
|
||||||
|
editSSLPrivateKey.Text := FOrgSSL_Key;
|
||||||
|
editSSLCertificate.Text := FOrgSSL_Cert;
|
||||||
|
editSSLCACertificate.Text := FOrgSSL_CA;
|
||||||
chkCompressed.Checked := FOrgCompressed;
|
chkCompressed.Checked := FOrgCompressed;
|
||||||
editStartupScript.Text := FOrgStartupScript;
|
editStartupScript.Text := FOrgStartupScript;
|
||||||
FLoaded := True;
|
FLoaded := True;
|
||||||
@ -530,11 +552,17 @@ begin
|
|||||||
if FLoaded then begin
|
if FLoaded then begin
|
||||||
if radioTypeTCPIP.Checked then NetType := NETTYPE_TCPIP
|
if radioTypeTCPIP.Checked then NetType := NETTYPE_TCPIP
|
||||||
else NetType := NETTYPE_NAMEDPIPE;
|
else NetType := NETTYPE_NAMEDPIPE;
|
||||||
FSessionModified := (FOrgHost <> editHost.Text) or (FOrgUser <> editUsername.Text)
|
|
||||||
or (FOrgPassword <> editPassword.Text) or (FOrgPort <> updownPort.Tag)
|
FSessionModified := (FOrgHost <> editHost.Text)
|
||||||
|
or (FOrgUser <> editUsername.Text)
|
||||||
|
or (FOrgPassword <> editPassword.Text)
|
||||||
|
or (FOrgPort <> updownPort.Tag)
|
||||||
or (FOrgCompressed <> chkCompressed.Checked)
|
or (FOrgCompressed <> chkCompressed.Checked)
|
||||||
or (FOrgNetType <> NetType)
|
or (FOrgNetType <> NetType)
|
||||||
or (FOrgStartupScript <> editStartupScript.Text);
|
or (FOrgStartupScript <> editStartupScript.Text)
|
||||||
|
or (FOrgSSL_Key <> editSSLPrivateKey.Text)
|
||||||
|
or (FOrgSSL_Cert <> editSSLCertificate.Text)
|
||||||
|
or (FOrgSSL_CA <> editSSLCACertificate.Text);
|
||||||
ListSessions.Repaint;
|
ListSessions.Repaint;
|
||||||
ValidateControls;
|
ValidateControls;
|
||||||
end;
|
end;
|
||||||
@ -542,15 +570,24 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
procedure Tconnform.radioNetTypeClick(Sender: TObject);
|
procedure Tconnform.radioNetTypeClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
IsTCP: Boolean;
|
||||||
begin
|
begin
|
||||||
// Toggle between TCP/IP and named pipes mode
|
// Toggle between TCP/IP and named pipes mode
|
||||||
if radioTypeTCPIP.Checked then
|
IsTCP := radioTypeTCPIP.Checked;
|
||||||
|
if IsTCP then
|
||||||
lblHost.Caption := 'Hostname / IP:'
|
lblHost.Caption := 'Hostname / IP:'
|
||||||
else
|
else
|
||||||
lblHost.Caption := 'Socket name:';
|
lblHost.Caption := 'Socket name:';
|
||||||
editPort.Enabled := radioTypeTCPIP.Checked;
|
lblPort.Enabled := IsTCP;
|
||||||
lblPort.Enabled := editPort.Enabled;
|
editPort.Enabled := lblPort.Enabled;
|
||||||
updownPort.Enabled := editPort.Enabled;
|
updownPort.Enabled := lblPort.Enabled;
|
||||||
|
lblSSLPrivateKey.Enabled := IsTCP;
|
||||||
|
editSSLPrivateKey.Enabled := lblSSLPrivateKey.Enabled;
|
||||||
|
lblSSLCACertificate.Enabled := IsTCP;
|
||||||
|
editSSLCACertificate.Enabled := lblSSLCACertificate.Enabled;
|
||||||
|
lblSSLCertificate.Enabled := IsTCP;
|
||||||
|
editSSLCertificate.Enabled := lblSSLCertificate.Enabled;
|
||||||
Modification(Sender);
|
Modification(Sender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -623,16 +660,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure Tconnform.editStartupScriptRightButtonClick(Sender: TObject);
|
procedure Tconnform.PickFile(Sender: TObject);
|
||||||
var
|
var
|
||||||
Selector: TOpenDialog;
|
Selector: TOpenDialog;
|
||||||
|
Edit: TButtonedEdit;
|
||||||
|
i: Integer;
|
||||||
|
Control: TControl;
|
||||||
begin
|
begin
|
||||||
// Select startup SQL file
|
// Select startup SQL file, SSL file or whatever button clicked
|
||||||
|
Edit := Sender as TButtonedEdit;
|
||||||
Selector := TOpenDialog.Create(Self);
|
Selector := TOpenDialog.Create(Self);
|
||||||
Selector.FileName := editStartupScript.Text;
|
Selector.FileName := editStartupScript.Text;
|
||||||
Selector.Filter := 'SQL-files (*.sql)|*.sql|All files (*.*)|*.*';
|
if Edit = editStartupScript then
|
||||||
|
Selector.Filter := 'SQL-files (*.sql)|*.sql|All files (*.*)|*.*'
|
||||||
|
else
|
||||||
|
Selector.Filter := 'Privacy Enhanced Mail certificates (*.pem)|*.pem|Certificates (*.crt)|*.crt|All files (*.*)|*.*';
|
||||||
|
// Find relevant label and set open dialog's title
|
||||||
|
for i:=0 to Edit.Parent.ControlCount - 1 do begin
|
||||||
|
Control := Edit.Parent.Controls[i];
|
||||||
|
if (Control is TLabel) and ((Control as TLabel).FocusControl = Edit) then begin
|
||||||
|
Selector.Title := 'Select ' + (Control as TLabel).Caption;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
if Selector.Execute then begin
|
if Selector.Execute then begin
|
||||||
editStartupScript.Text := Selector.FileName;
|
Edit.Text := Selector.FileName;
|
||||||
Modification(Selector);
|
Modification(Selector);
|
||||||
end;
|
end;
|
||||||
Selector.Free;
|
Selector.Free;
|
||||||
|
@ -122,6 +122,9 @@ const
|
|||||||
DEFAULT_PASSWORD = '';
|
DEFAULT_PASSWORD = '';
|
||||||
REGNAME_PORT = 'Port';
|
REGNAME_PORT = 'Port';
|
||||||
DEFAULT_PORT = 3306;
|
DEFAULT_PORT = 3306;
|
||||||
|
REGNAME_SSL_KEY = 'SSL_Key';
|
||||||
|
REGNAME_SSL_CERT = 'SSL_Cert';
|
||||||
|
REGNAME_SSL_CA = 'SSL_CA';
|
||||||
REGNAME_NETTYPE = 'NetType';
|
REGNAME_NETTYPE = 'NetType';
|
||||||
DEFAULT_NETTYPE = NETTYPE_TCPIP;
|
DEFAULT_NETTYPE = NETTYPE_TCPIP;
|
||||||
REGNAME_COMPRESSED = 'Compressed';
|
REGNAME_COMPRESSED = 'Compressed';
|
||||||
|
@ -1527,6 +1527,9 @@ begin
|
|||||||
LoadedParams.Username := GetRegValue(REGNAME_USER, DEFAULT_USER, LastSession);
|
LoadedParams.Username := GetRegValue(REGNAME_USER, DEFAULT_USER, LastSession);
|
||||||
LoadedParams.Password := decrypt(GetRegValue(REGNAME_PASSWORD, DEFAULT_PASSWORD, LastSession));
|
LoadedParams.Password := decrypt(GetRegValue(REGNAME_PASSWORD, DEFAULT_PASSWORD, LastSession));
|
||||||
LoadedParams.Port := StrToIntDef(GetRegValue(REGNAME_PORT, '', LastSession), DEFAULT_PORT);
|
LoadedParams.Port := StrToIntDef(GetRegValue(REGNAME_PORT, '', LastSession), DEFAULT_PORT);
|
||||||
|
LoadedParams.SSLPrivateKey := GetRegValue(REGNAME_SSL_KEY, '', LastSession);
|
||||||
|
LoadedParams.SSLCertificate := GetRegValue(REGNAME_SSL_CERT, '', LastSession);
|
||||||
|
LoadedParams.SSLCACertificate := GetRegValue(REGNAME_SSL_CA, '', LastSession);
|
||||||
LoadedParams.StartupScriptFilename := GetRegValue(REGNAME_STARTUPSCRIPT, DEFAULT_STARTUPSCRIPT, LastSession);
|
LoadedParams.StartupScriptFilename := GetRegValue(REGNAME_STARTUPSCRIPT, DEFAULT_STARTUPSCRIPT, LastSession);
|
||||||
if GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, LastSession) then
|
if GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, LastSession) then
|
||||||
LoadedParams.Options := LoadedParams.Options + [opCompress]
|
LoadedParams.Options := LoadedParams.Options + [opCompress]
|
||||||
@ -1614,6 +1617,9 @@ begin
|
|||||||
FCmdlineConnectionParams.Username := GetRegValue(REGNAME_USER, DEFAULT_USER, FCmdlineSessionName);
|
FCmdlineConnectionParams.Username := GetRegValue(REGNAME_USER, DEFAULT_USER, FCmdlineSessionName);
|
||||||
FCmdlineConnectionParams.Password := decrypt(GetRegValue(REGNAME_PASSWORD, DEFAULT_PASSWORD, FCmdlineSessionName));
|
FCmdlineConnectionParams.Password := decrypt(GetRegValue(REGNAME_PASSWORD, DEFAULT_PASSWORD, FCmdlineSessionName));
|
||||||
FCmdlineConnectionParams.Port := StrToIntDef(GetRegValue(REGNAME_PORT, '', FCmdlineSessionName), DEFAULT_PORT);
|
FCmdlineConnectionParams.Port := StrToIntDef(GetRegValue(REGNAME_PORT, '', FCmdlineSessionName), DEFAULT_PORT);
|
||||||
|
FCmdlineConnectionParams.SSLPrivateKey := GetRegValue(REGNAME_SSL_KEY, '', FCmdlineSessionName);
|
||||||
|
FCmdlineConnectionParams.SSLCertificate := GetRegValue(REGNAME_SSL_CERT, '', FCmdlineSessionName);
|
||||||
|
FCmdlineConnectionParams.SSLCACertificate := GetRegValue(REGNAME_SSL_CA, '', FCmdlineSessionName);
|
||||||
FCmdlineConnectionParams.StartupScriptFilename := GetRegValue(REGNAME_STARTUPSCRIPT, DEFAULT_STARTUPSCRIPT, FCmdlineSessionName);
|
FCmdlineConnectionParams.StartupScriptFilename := GetRegValue(REGNAME_STARTUPSCRIPT, DEFAULT_STARTUPSCRIPT, FCmdlineSessionName);
|
||||||
if GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, FCmdlineSessionName) then
|
if GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, FCmdlineSessionName) then
|
||||||
FCmdlineConnectionParams.Options := FCmdlineConnectionParams.Options + [opCompress]
|
FCmdlineConnectionParams.Options := FCmdlineConnectionParams.Options + [opCompress]
|
||||||
@ -2447,6 +2453,9 @@ begin
|
|||||||
Params.Username := GetRegValue(REGNAME_USER, '', Session);
|
Params.Username := GetRegValue(REGNAME_USER, '', Session);
|
||||||
Params.Password := decrypt(GetRegValue(REGNAME_PASSWORD, '', Session));
|
Params.Password := decrypt(GetRegValue(REGNAME_PASSWORD, '', Session));
|
||||||
Params.Port := StrToIntDef(GetRegValue(REGNAME_PORT, '', Session), DEFAULT_PORT);
|
Params.Port := StrToIntDef(GetRegValue(REGNAME_PORT, '', Session), DEFAULT_PORT);
|
||||||
|
Params.SSLPrivateKey := GetRegValue(REGNAME_SSL_KEY, '', Session);
|
||||||
|
Params.SSLCertificate := GetRegValue(REGNAME_SSL_CERT, '', Session);
|
||||||
|
Params.SSLCACertificate := GetRegValue(REGNAME_SSL_CA, '', Session);
|
||||||
Params.StartupScriptFilename := GetRegValue(REGNAME_STARTUPSCRIPT, '', Session);
|
Params.StartupScriptFilename := GetRegValue(REGNAME_STARTUPSCRIPT, '', Session);
|
||||||
if GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, Session) then
|
if GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, Session) then
|
||||||
Params.Options := Params.Options + [opCompress]
|
Params.Options := Params.Options + [opCompress]
|
||||||
|
@ -47,7 +47,8 @@ type
|
|||||||
|
|
||||||
TConnectionParameters = class(TObject)
|
TConnectionParameters = class(TObject)
|
||||||
strict private
|
strict private
|
||||||
FHostname, FSocketname, FUsername, FPassword, FStartupScriptFilename: String;
|
FHostname, FSocketname, FUsername, FPassword, FStartupScriptFilename,
|
||||||
|
FSSLPrivateKey, FSSLCertificate, FSSLCACertificate: String;
|
||||||
FPort: Integer;
|
FPort: Integer;
|
||||||
FOptions: TMySQLClientOptions;
|
FOptions: TMySQLClientOptions;
|
||||||
public
|
public
|
||||||
@ -60,6 +61,9 @@ type
|
|||||||
property Password: String read FPassword write FPassword;
|
property Password: String read FPassword write FPassword;
|
||||||
property StartupScriptFilename: String read FStartupScriptFilename write FStartupScriptFilename;
|
property StartupScriptFilename: String read FStartupScriptFilename write FStartupScriptFilename;
|
||||||
property Options: TMySQLClientOptions read FOptions write FOptions;
|
property Options: TMySQLClientOptions read FOptions write FOptions;
|
||||||
|
property SSLPrivateKey: String read FSSLPrivateKey write FSSLPrivateKey;
|
||||||
|
property SSLCertificate: String read FSSLCertificate write FSSLCertificate;
|
||||||
|
property SSLCACertificate: String read FSSLCACertificate write FSSLCACertificate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -216,6 +220,9 @@ begin
|
|||||||
FUsername := DEFAULT_USER;
|
FUsername := DEFAULT_USER;
|
||||||
FPassword := '';
|
FPassword := '';
|
||||||
FPort := DEFAULT_PORT;
|
FPort := DEFAULT_PORT;
|
||||||
|
FSSLPrivateKey := '';
|
||||||
|
FSSLCertificate := '';
|
||||||
|
FSSLCACertificate := '';
|
||||||
FStartupScriptFilename := DEFAULT_STARTUPSCRIPT;
|
FStartupScriptFilename := DEFAULT_STARTUPSCRIPT;
|
||||||
FOptions := [opCompress, opLocalFiles, opInteractive, opProtocol41, opMultiStatements];
|
FOptions := [opCompress, opLocalFiles, opInteractive, opProtocol41, opMultiStatements];
|
||||||
end;
|
end;
|
||||||
@ -254,7 +261,9 @@ var
|
|||||||
Connected: PMYSQL;
|
Connected: PMYSQL;
|
||||||
ClientFlags: Integer;
|
ClientFlags: Integer;
|
||||||
Error, tmpdb: String;
|
Error, tmpdb: String;
|
||||||
|
SSLResult: Byte;
|
||||||
UsingPass, Protocol, CurCharset: String;
|
UsingPass, Protocol, CurCharset: String;
|
||||||
|
IsNamedPipe: Boolean;
|
||||||
begin
|
begin
|
||||||
FActive := Value;
|
FActive := Value;
|
||||||
|
|
||||||
@ -262,6 +271,32 @@ begin
|
|||||||
// Get handle
|
// Get handle
|
||||||
FHandle := mysql_init(nil);
|
FHandle := mysql_init(nil);
|
||||||
|
|
||||||
|
// Prepare connection
|
||||||
|
IsNamedPipe := FParameters.Hostname = '.';
|
||||||
|
if IsNamedPipe then Protocol := 'named pipe' else Protocol := 'TCP/IP';
|
||||||
|
if FParameters.Password <> '' then UsingPass := 'Yes' else UsingPass := 'No';
|
||||||
|
Log(lcInfo, 'Connecting to '+FParameters.Hostname+' via '+Protocol+
|
||||||
|
', username '+FParameters.Username+
|
||||||
|
', using password: '+UsingPass+' ...');
|
||||||
|
|
||||||
|
// Be sure we don't pass mutually exclusive options
|
||||||
|
if not IsNamedPipe and
|
||||||
|
(FParameters.SSLPrivateKey <> '') and
|
||||||
|
(FParameters.SSLCertificate <> '') and
|
||||||
|
(FParameters.SSLCACertificate <> '') then begin
|
||||||
|
FParameters.Options := FParameters.Options + [opSSL];
|
||||||
|
{ TODO : Use Cipher and CAPath parameters }
|
||||||
|
SSLResult := mysql_ssl_set(
|
||||||
|
FHandle,
|
||||||
|
PansiChar(AnsiString(FParameters.SSLPrivateKey)),
|
||||||
|
PansiChar(AnsiString(FParameters.SSLCertificate)),
|
||||||
|
PansiChar(AnsiString(FParameters.SSLCACertificate)),
|
||||||
|
{PansiChar(AnsiString(FParameters.CApath))}nil,
|
||||||
|
{PansiChar(AnsiString(FParameters.Cipher))}nil);
|
||||||
|
if SSLresult <> 0 then
|
||||||
|
raise Exception.CreateFmt('Could not connect using SSL (Error %d)', [SSLresult]);
|
||||||
|
end;
|
||||||
|
|
||||||
// Gather client options
|
// Gather client options
|
||||||
ClientFlags := 0;
|
ClientFlags := 0;
|
||||||
if opRememberOptions in FParameters.Options then ClientFlags := ClientFlags or CLIENT_REMEMBER_OPTIONS;
|
if opRememberOptions in FParameters.Options then ClientFlags := ClientFlags or CLIENT_REMEMBER_OPTIONS;
|
||||||
@ -285,12 +320,6 @@ begin
|
|||||||
if opMultiResults in FParameters.Options then ClientFlags := ClientFlags or CLIENT_MULTI_RESULTS;
|
if opMultiResults in FParameters.Options then ClientFlags := ClientFlags or CLIENT_MULTI_RESULTS;
|
||||||
if opRememberOptions in FParameters.Options then ClientFlags := ClientFlags or CLIENT_REMEMBER_OPTIONS;
|
if opRememberOptions in FParameters.Options then ClientFlags := ClientFlags or CLIENT_REMEMBER_OPTIONS;
|
||||||
|
|
||||||
// Prepare connection
|
|
||||||
if FParameters.Hostname = '.' then Protocol := 'named pipe' else Protocol := 'TCP/IP';
|
|
||||||
if FParameters.Password <> '' then UsingPass := 'Yes' else UsingPass := 'No';
|
|
||||||
Log(lcInfo, 'Connecting to '+FParameters.Hostname+' via '+Protocol+
|
|
||||||
', username '+FParameters.Username+
|
|
||||||
', using password: '+UsingPass+' ...');
|
|
||||||
Connected := mysql_real_connect(
|
Connected := mysql_real_connect(
|
||||||
FHandle,
|
FHandle,
|
||||||
PAnsiChar(Utf8Encode(FParameters.Hostname)),
|
PAnsiChar(Utf8Encode(FParameters.Hostname)),
|
||||||
|
Reference in New Issue
Block a user