locked
FtpWebRequest with SSL RRS feed

  • Question

  • Hi All,

     

    I am getting the following exception when trying to enable SSL with FtpWebRequest.

     

    "The remote server returned an error: 234 AUTH Command OK. Initializing SSL connection".

     

    I have an SSL wrapper (Glub) around IIS 6.0 Ftp server and it works with commercial ftp client (Glub).

     

    The ftp program has been working without SSL.

    ANY HELP IS APPRECIATED.

     

    My code is as follows:

     

    try

    {

    ftpRequest = (FtpWebRequest)WebRequest.Create(strDirectoryFullFtpUri);

    ftpRequest.EnableSsl = true;

    //X509Store store = new X509Store("teststore", StoreLocation.CurrentUser);

    //store.Open(OpenFlags.ReadWrite);

    X509Certificate2 certificate = new X509Certificate2("F:\\EtreppidSurveillanceSystem\\eTCaptureAgent-Embedded-WCF\\TestCLRConsoleApp\\TestCLRConsoleApp\\lalith.pfx", "etreppid");

    ftpRequest.ClientCertificates.Add(certificate);

    ftpRequest.UsePassive = true;

    ftpRequest.Method = WebRequestMethods.Ftp.MakeDirectory;

    ftpRequest.Credentials = new NetworkCredential("etreppid-ave", "etreppid");

    FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();

    if (ftpResponse.StatusCode != FtpStatusCode.PathnameCreated)

    {

    m_strLogMsg = String.Format("Create Directory on Ftp server returned status code {0}: {1}.\n",

    ftpResponse.StatusCode, ftpResponse.StatusDescription);

    eTLogFile.LogMsg(m_strLogMsg);

    Trace.Write(m_strLogMsg);

    }

    }

    catch (Exception e)

    {

    m_strLogMsg = String.Format("Create Directory on Ftp server raised an exception {0}.\n",

    e.Message);

    eTLogFile.LogMsg(m_strLogMsg);

    Trace.Write(m_strLogMsg);

    ftpRequest = null;

    return false;

    }

     

     

    Any help is appreciated

    Thursday, April 3, 2008 11:13 PM