SSH key as resource

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
JimBalo
Posts: 5
Joined: Sat 23 Jan 2010 03:19

SSH key as resource

Post by JimBalo » Sat 23 Jan 2010 03:35

Hello,

I am trying to specify the SSH PrivateKey as an "compiled resource" following http://www.devart.com/dotconnect/mysql/ ... tions.html, but I keep getting an exception that it cannot find the resource.

I have tried every which way. I have added the key file as an "embedded resource" (by the Build Action property) and I have also tried putting the key in resources.resx, but nothing seems to work. Of course I set PrivateKey = "resource://whatever.key" The solution is multi-project WinForm app. Does the resource go in the output project, or in the data access layer project??

Could you please post a simple C# sample project with an SSH key as a compiled resource with a short snippet that uses it?

Cheers!
Jim

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 25 Jan 2010 16:48

To use the SSH private key as a compiled resource, you may perform the following:

1. Add the client.key file containing the private key to the root of your DAL project.
2. Set the "Embedded resource" compile option for this file.
3. Specify the file's name in MySqlConnection.SshOptions:

Code: Select all

mySqlConnection1.SshOptions.PrivateKey = "resource://client.key";
I send a sample project to the email you've provided in your forum profile. Please check that the letter is not blocked by your mail filter.

Also, please check that you are able to connect to your SSH server using some standard tool.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 26 Jan 2010 13:34

Also try adding your project name before the name of your private key:

Code: Select all

mySqlConnection1.SshOptions.PrivateKey = "resource://MyProject.client.key";

JimBalo
Posts: 5
Joined: Sat 23 Jan 2010 03:19

Post by JimBalo » Wed 27 Jan 2010 02:02

Hello,

I tried the attached sample, and it works with that. It also works with any project I create from scratch. But for some reason it does not work with the existing app I tried with. So I stripped that app down to a very simple sample and emailed it to you so that you can check it out.

I use the exact same connection string and key that I use in the working sample, but for some reason it "Cannot connect to server" in the solution I emailed you. Very peculiar.

Please check out and let me know.

Cheers!
Jim

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 27 Jan 2010 12:46

We will investigate the problem and inform you about the results.

JimBalo
Posts: 5
Joined: Sat 23 Jan 2010 03:19

Post by JimBalo » Tue 02 Feb 2010 15:39

Please give status on this.

Thanks,
Jim

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 02 Feb 2010 16:14

The correct format of the resource identifier is

Code: Select all

resource://MyAssembly,%ResourcePath%
where MyAssembly stands for the assembly into which the resource is embedded, and ResourcePath is the complete path to the resource in the project. To determine the assembly name you can, e.g., check the "Assembly Name" field in the properties of the project containing the resource.

For example, in the project you've sent us the resource identifier for the private key should be

Code: Select all

resource://BusinessLayer,client.key

JimBalo
Posts: 5
Joined: Sat 23 Jan 2010 03:19

Post by JimBalo » Wed 03 Feb 2010 02:12

That works. Maybe something you could put in your documentation?

Also, and pardon my ignorance, I noticed that the key as a resource is visible in plain text in the compiled assembly. I noticed another post about adding a property for providing the key as a string instead. This would work much better for me. Having the private key in plain view kind of defeats the purpose of using SSH in the first place. But I'll add a post to that thread asking for ETA, etc.

Cheers!
Jim

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 03 Feb 2010 10:41

Thank you for your suggestions. We will add the information about the resource identifier format to the documentation.

Post Reply