SSH key as resource
SSH key as resource
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
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
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10: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:
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.
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";
Also, please check that you are able to connect to your SSH server using some standard tool.
Also try adding your project name before the name of your private key:
Code: Select all
mySqlConnection1.SshOptions.PrivateKey = "resource://MyProject.client.key";
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
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
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
The correct format of the resource identifier is
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://MyAssembly,%ResourcePath%
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
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
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
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48