alex ftps error - Policy requires SSL.

Jan 9, 2014 at 10:04 AM
Edited Jan 9, 2014 at 10:22 AM
IIS7-> we have enabled checkbox Require ssl connections. our code is as follows. we are using a valid certficate generated by CA.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AlexPilotti.FTPS.Client;
using AlexPilotti.FTPS.Common;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

namespace FTPSTest
{
class Program
{
    static void Main(string[] args)
    {
        using (FTPSClient client = new FTPSClient())
        {

            client.Connect("000.00.000.000", new NetworkCredential("user1","Password"), ESSLSupportMode.CredentialsRequired | ESSLSupportMode.DataChannelRequested, new RemoteCertificateValidationCallback(ValidateTestServerCertificate));
            client.PutFile("tryme.txt", "tryme.txt");
        }


    }
    private static bool ValidateTestServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    {



       if (sslPolicyErrors == SslPolicyErrors.None)
            return true;
        else
        {
            return false;
        }

    }

}
}
*************************************8
we are GETTING BELOW ERROR
AlexPilotti.FTPS.Common.FTPCommandException was unhandled
Message=Policy requires SSL.
Source=AlexPilotti.FTPS.Client
ErrorCode=534
StackTrace:
   at AlexPilotti.FTPS.Client.FTPSClient.GetReply()
   at AlexPilotti.FTPS.Client.FTPSClient.HandleCmd(String command, Boolean waitForAnswer)
   at AlexPilotti.FTPS.Client.FTPSClient.HandleCmd(String command)
   at AlexPilotti.FTPS.Client.FTPSClient.CccCmd()
   at AlexPilotti.FTPS.Client.FTPSClient.SSlCtrlChannelCheckRevertToClearText()
   at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData, EDataConnectionMode dataConnectionMode)
   at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData)
   at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout)
   at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate)
   at FTPSTest.Program.Main(String[] args) in C:\Users\user1\Documents\Visual Studio 2010\Projects\FTPSTest\FTPSTest\Program.cs:line 36
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:

it works when checkbox "Allow ssl connections" is enabled
but doesnt work if checkbox "Require ssl connections" checkbox is enabled.
what could be the reason???
Jan 11, 2014 at 4:10 AM
it is working with below code..

client.Connect("000.00.000.000", port, new NetworkCredential("user1", "Password"), ESSLSupportMode.All, new RemoteCertificateValidationCallback(ValidateTestServerCertificate), new X509Certificate(), 0, 0, 0, System.Threading.Timeout.Infinite);

client.PutFile("Tester.txt", "Tester.txt");