I wonder what the way is to Login to my FTP server with encrypted UserName and Password ?

Normally when you login to a FTP Server, the UserName and Password travels as plain "text" wich could be "Hijacked" on the way.

I wonder if there is a way to send the UserName and Password Encrypted when logging in to the FTP Server ?


(These are some of the lines when doing the connection. Full code is avaliable)


String FilePath = "ftp://website.com:21/Data/";

objRequest = (FtpWebRequest)WebRequest.Create(FilePath);

objRequest.Credentials = new NetworkCredential("User", "Password");

//What is needed to do in order to do this connection encrypted ?

Thank you Salem for your answer. It is not possible for me to use SFTP as it is not a service at Godaddy.com.
I have now for the past 2 days have an email discussion with godaddy about the FTP-SSL and this is now the answer about my hostingaccount wich ofcourse is positive:

FTP-SSL is enabled and working on your account. There is nothing further you need to do to use FTP-SSL with your account. If you are developing an application that requires connecting to FTP over a secure connection, please be sure you have your coding set properly to use FTP-SSL as the connection method.

So now is my big question if I really have the connectioncode correct to do the connection over FTP-SSL ?

When I try this code with enableSsl = true; the Exceptionerror that I get in the catch event says this:

"System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure"

I am really stuck and really wonder if something is missing out in the code below or if anything has to be changed. Godaddy says that if it is any wrong anywhere it has to be in my code(They donĀ“t have any coding support).

(Code to connect to Server with FTP-SSL)

String^ FilePath;
FtpWebRequest^ objRequest;
FtpWebResponse^ objResponse;
Stream^ responseStream;


try 

{

//First a request to FTP Server shall be initiated, requesting the file needed.
FilePath = "ftp://testing.info/Folder1/DataBase/" + textBox1->Text->Trim() + ".txt"; 

//Create just "Creates" a new WebRequest for that path, then comes the actions:
objRequest = (FtpWebRequest^)WebRequest::Create(FilePath);

//Set a timeout for the connection
objRequest->Timeout = 10000;

//Use SSL certificate
objRequest->EnableSsl = true; //Use SSL to transfer secure

objRequest->Credentials = gcnew NetworkCredential("User", "Password");  

//Then, we have to get the response for this request:
objResponse = (FtpWebResponse^) objRequest->GetResponse();

//Get the stream of file with the response:
responseStream = objResponse->GetResponseStream();
 }

     catch(Exception^ ex2)
     {

                     String^ ExceptionMsg = ex2;
                     MessageBox:: Show(ExceptionMsg);

     }

You need a different protocol.

Say
http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol

To simplify the last post is that when using the "correct" code to login with FTP-SSL, this exception is throwed:

"System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure"


However I have googled around and found very diffus information about that you in the code also have to "Accept" different certificates in

order to make it work but I am not sure of the fact as it is very diffus ?

I have a research but though it is difficult to find what is nessecary to add in the code.
I have come over some information where it perheps is nessecary to accept all certificates here:
http://fabioscagliola.spaces.live.com/blog/cns!919F8FCDE3DC9AC4!154.entry?sa=204643560

The code that is shown is in C#. However I would need this code in C++.

How would it be possible to convert this to C++ ?
(VC++ 2008 Express Edition)

using System;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

public static bool ValidateServerCertificate(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
   return true;
}

2) Create the RemoteCertificateValidationCallback delegate using the method defined in the preceding code example and assign it to the ServerCertificateValidationCallback property of the ServicePointManager class.

using System.Net;
using System.Net.Security;

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.