1
Vote

ftp over tls

description

Hi all,

i' m trying to support TLS with this ftp project. but facing issue. in order to handle Data socket in secure way,

i've added following code
__public static X509Certificate2 GetCertificate()
{
string certificate = @"C:\Users\...\server.pfx"; if (serverCertificate == null )
serverCertificate = new X509Certificate2(certificate, "");

return serverCertificate;

}

TcpListener listener = SocketHelpers.CreateTcpListener(endpoint);
listener.Start();
TcpClient socket = listener.AcceptTcpClient();

//wrap networkstream with ssl
SslStream sslStream = new SslStream(socket.GetStream(),false);

// following line execution is too slow...
stream.AuthenticateAsServer(GetCertificate(), false, SslProtocols.Tls12, true);

//following line throws System.ArgumentException "Stream was not writable"
var writer = new BinaryWriter(sslStream);
writer.Write(abMessage, nStart, nLength);
writer.Flush();__

But SslStream sslStream = new SslStream(socket.GetStream(),false); is causing long delay.
Note that i'm using passive mode.

please can someone advice ? or eventually share his FTPS project ?

many thanks in advance.

comments