Problem Selecting .ppk Key

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
ja_sws
Posts: 4
Joined: Mon 16 Apr 2018 08:17

Problem Selecting .ppk Key

Post by ja_sws » Mon 16 Apr 2018 08:29

Using Rad Studio 10.2, C++ Builder
I have placed an instance of ScFileStorage on the main form and opened the Edit window and tried to add a key from a Putty .ppk file using the Import from... button but it gives and Error saying Password not specified.
I have used this key file to make a connection using Putty so I know the key is good.
Here are the details from the error window:
[2862BD07]{sbridge250.bpl} Scbridge.TScKey.ParsePuTTYKey + $3A7
[2862CCD4]{sbridge250.bpl} Scbridge.TScKey.ImportFrom + $1C0
[2862D7D1]{sbridge250.bpl} Scbridge.TScKey.ImportFrom + $49
[0600845D]{dclsbridge250.bpl} Sckeysframe.TScKeyEdit.ImportKey + $C5
[06009A45]{dclsbridge250.bpl} Sckeysframe.TScKeysFrame.btImportClick + $2D
[50AB5177]{vcl250.bpl } Vcl.Controls.TControl.Click (Line 7442, "Vcl.Controls.pas" + 9) + $8
[50ADAE8A]{vcl250.bpl } Vcl.StdCtrls.TCustomButton.Click (Line 5441, "Vcl.StdCtrls.pas" + 3) + $2
[50ADB998]{vcl250.bpl } Vcl.StdCtrls.TCustomButton.CNCommand (Line 5902, "Vcl.StdCtrls.pas" + 1) + $D
[50AB4C0A]{vcl250.bpl } Vcl.Controls.TControl.WndProc (Line 7326, "Vcl.Controls.pas" + 91) + $6
[50AB977D]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc (Line 10160, "Vcl.Controls.pas" + 158) + $6
[50ADAB34]{vcl250.bpl } Vcl.StdCtrls.TButtonControl.WndProc (Line 5278, "Vcl.StdCtrls.pas" + 13) + $4
[50AB4844]{vcl250.bpl } Vcl.Controls.TControl.Perform (Line 7104, "Vcl.Controls.pas" + 10) + $8
[50AB98E3]{vcl250.bpl } Vcl.Controls.DoControlMsg (Line 10229, "Vcl.Controls.pas" + 12) + $11
[50ABA36F]{vcl250.bpl } Vcl.Controls.TWinControl.WMCommand (Line 10504, "Vcl.Controls.pas" + 1) + $5
[50AB4C0A]{vcl250.bpl } Vcl.Controls.TControl.WndProc (Line 7326, "Vcl.Controls.pas" + 91) + $6
[50AB988E]{vcl250.bpl } Vcl.Controls.TWinControl.DefaultHandler (Line 10201, "Vcl.Controls.pas" + 30) + $19
[50AB4C0A]{vcl250.bpl } Vcl.Controls.TControl.WndProc (Line 7326, "Vcl.Controls.pas" + 91) + $6
[50AB977D]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc (Line 10160, "Vcl.Controls.pas" + 158) + $6
[21192502]{designide250.bpl} DeskUtil.SetFocusHook (Line 463, "DeskUtil.pas" + 4) + $C
[50AB8D9C]{vcl250.bpl } Vcl.Controls.TWinControl.MainWndProc (Line 9867, "Vcl.Controls.pas" + 3) + $6
[5016E844]{rtl250.bpl } System.Classes.StdWndProc (Line 17365, "System.Classes.pas" + 9) + $2
[50AB988E]{vcl250.bpl } Vcl.Controls.TWinControl.DefaultHandler (Line 10201, "Vcl.Controls.pas" + 30) + $19
[50AB55CC]{vcl250.bpl } Vcl.Controls.TControl.WMLButtonUp (Line 7575, "Vcl.Controls.pas" + 1) + $6
[50AB4C0A]{vcl250.bpl } Vcl.Controls.TControl.WndProc (Line 7326, "Vcl.Controls.pas" + 91) + $6
[0BF35164]{TrackingSystem250.bpl} TrackingSystemHelp.CBTHookProc (Line 211, "TrackingSystemHelp.pas" + 27) + $F
[50AB8F8B]{vcl250.bpl } Vcl.Controls.TWinControl.IsControlMouseMsg (Line 9923, "Vcl.Controls.pas" + 1) + $9
[50AB977D]{vcl250.bpl } Vcl.Controls.TWinControl.WndProc (Line 10160, "Vcl.Controls.pas" + 158) + $6
[50ADAB34]{vcl250.bpl } Vcl.StdCtrls.TButtonControl.WndProc (Line 5278, "Vcl.StdCtrls.pas" + 13) + $4
[50AB8D9C]{vcl250.bpl } Vcl.Controls.TWinControl.MainWndProc (Line 9867, "Vcl.Controls.pas" + 3) + $6
[5016E844]{rtl250.bpl } System.Classes.StdWndProc (Line 17365, "System.Classes.pas" + 9) + $2
[50C01963]{vcl250.bpl } Vcl.Forms.TApplication.ProcessMessage (Line 10610, "Vcl.Forms.pas" + 23) + $1
[50C019A6]{vcl250.bpl } Vcl.Forms.TApplication.HandleMessage (Line 10640, "Vcl.Forms.pas" + 1) + $4
[50BFCD62]{vcl250.bpl } Vcl.Forms.TCustomForm.ShowModal (Line 7362, "Vcl.Forms.pas" + 33) + $5
[06011A76]{dclsbridge250.bpl} Scstorageeditor.TScStorageForm.SetComponent + $E
[060146F9]{dclsbridge250.bpl} Scdesign.TScStorageEditor.ExecuteVerb + $51
[0C009E92]{fmxdesigner250.bpl} FmxSurface.TFmxDesignSurface.ComponentVerb (Line 6096, "FmxSurface.pas" + 3) + $B
[50BE51DE]{vcl250.bpl } Vcl.Menus.TMenuItem.Click (Line 2541, "Vcl.Menus.pas" + 19) + $8
[0BFF66F0]{fmxdesigner250.bpl} FMXMenus.TMenuItemWrapper.Click (Line 301, "FMXMenus.pas" + 1) + $5
[211CAC93]{designide250.bpl} TreeIntf.TStructureMenuItem.Invoke (Line 4419, "TreeIntf.pas" + 6) + $5
[211BB973]{designide250.bpl} StructureViewAPI.TStructureMenuItem.Click (Line 507, "StructureViewAPI.pas" + 6) + $9
[50BE6928]{vcl250.bpl } Vcl.Menus.TMenu.DispatchCommand (Line 3482, "Vcl.Menus.pas" + 5) + $4
[50BE7BBA]{vcl250.bpl } Vcl.Menus.TPopupList.WndProc (Line 4655, "Vcl.Menus.pas" + 4) + $E
[50060258]{rtl250.bpl } System.TMonitor.CheckOwningThread (Line 18501, "System.pas" + 2) + $0
[50060566]{rtl250.bpl } System.TMonitor.Exit (Line 18691, "System.pas" + 1) + $2
[500605B7]{rtl250.bpl } System.TMonitor.Exit (Line 18713, "System.pas" + 2) + $7
[50A9649B]{vcl250.bpl } Vcl.Graphics.FreeMemoryContexts (Line 7129, "Vcl.Graphics.pas" + 12) + $8
[50AB8D9C]{vcl250.bpl } Vcl.Controls.TWinControl.MainWndProc (Line 9867, "Vcl.Controls.pas" + 3) + $6
[50BE7B09]{vcl250.bpl } Vcl.Menus.TPopupList.MainWndProc (Line 4630, "Vcl.Menus.pas" + 2) + $5
[5016E844]{rtl250.bpl } System.Classes.StdWndProc (Line 17365, "System.Classes.pas" + 9) + $2
[50C01963]{vcl250.bpl } Vcl.Forms.TApplication.ProcessMessage (Line 10610, "Vcl.Forms.pas" + 23) + $1
[50C019A6]{vcl250.bpl } Vcl.Forms.TApplication.HandleMessage (Line 10640, "Vcl.Forms.pas" + 1) + $4
[50C01CD9]{vcl250.bpl } Vcl.Forms.TApplication.Run (Line 10778, "Vcl.Forms.pas" + 26) + $3
[0050688A]{bds.exe } bds.bds (Line 212, "" + 7) + $7

ViktorV
Devart Team
Posts: 2120
Joined: Wed 30 Jul 2014 07:16

Re: Problem Selecting .ppk Key

Post by ViktorV » Mon 16 Apr 2018 11:00

This error occurs when trying to import a private key file that is password-protected. Such keys should be imported at runtime, they can not be imported at designtime. For example:

Code: Select all

// the password protected private key
var
Key: TScKey;
...
Key:=TScKey.Create(ScFileStorage.Keys);
Key.KeyName:='private_key';
Key.ImportFrom('C:\privatekey.ppk', password_for_key);

ja_sws
Posts: 4
Joined: Mon 16 Apr 2018 08:17

Re: Problem Selecting .ppk Key

Post by ja_sws » Mon 16 Apr 2018 12:42

Thank you for your reply. I had no chance of working that out. I really appreciate it.
I will try it tomorrow and let you know how it goes.
The key was originally in openssh format and I used puttygen to convert it but it did require a passphrase. I guess I will check whether puttygen has an option to remove the passphrase.

ja_sws
Posts: 4
Joined: Mon 16 Apr 2018 08:17

Re: Problem Selecting .ppk Key

Post by ja_sws » Tue 17 Apr 2018 04:22

Hi ViktorV,

I was able to import the password protected key at runtime using the method you suggested.
I noticed that it remains in the TscFileStorage after the application has run once so there is no need to run it again.
It seems strange to me that the edit window for TscFileStorage doesn't include an option to enter the password so the key can be loaded at design time.

I found that I had to handle the TScSSHClient.OnServerKeyValidate event and pass Accept=True as explained here: viewtopic.php?f=27&t=36949. The key that I have has both private and public keys but the fingerprint doesn't match the one for the key that is returned by the server during the connection. I don't understand how the connection can work if the keys don't match?

Thank you very much for your help. You got me up and running.

ViktorV
Devart Team
Posts: 2120
Joined: Wed 30 Jul 2014 07:16

Re: Problem Selecting .ppk Key

Post by ViktorV » Tue 17 Apr 2018 13:53

For authentication, SSH protocol uses two different keys: the server and client ones. The server key is used to authenticate the SSH server and is verified on the client. Its name is specified in the TScSSHClient.HostKeyName property. The client key is used to authenticate the client and is verified on the SSH server. Its name is specified in the TScSSHClient.PrivateKeyName property.

ja_sws
Posts: 4
Joined: Mon 16 Apr 2018 08:17

Re: Problem Selecting .ppk Key

Post by ja_sws » Thu 19 Apr 2018 02:57

Thanks for explaining that. I have used the TScSSHClient.OnServerKeyValidate event now to save the host key to the FileStorage as well.
Thanks for your help.

ViktorV
Devart Team
Posts: 2120
Joined: Wed 30 Jul 2014 07:16

Re: Problem Selecting .ppk Key

Post by ViktorV » Thu 19 Apr 2018 12:39

Glad to see that the issue was resolved.
Feel free to contact us if you have any further questions about our products.

Post Reply