Fix TLS negociations order
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Security;
|
||||
using System.Text;
|
||||
|
||||
namespace DearFTP.Connection.Commands
|
||||
@@ -31,6 +32,8 @@ namespace DearFTP.Connection.Commands
|
||||
|
||||
stream.Send(ResponseCode.FileStatusOK, "Listing coming.");
|
||||
|
||||
dataConnection.Authenticate();
|
||||
|
||||
string path = null;
|
||||
bool humanReadable = false;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Security;
|
||||
|
||||
namespace DearFTP.Connection.Commands
|
||||
{
|
||||
@@ -71,6 +72,8 @@ namespace DearFTP.Connection.Commands
|
||||
|
||||
stream.Send(ResponseCode.FileStatusOK, "Listing coming.");
|
||||
|
||||
dataConnection.Authenticate();
|
||||
|
||||
var dataStream = new FtpStream(dataConnection.Stream);
|
||||
|
||||
foreach (var info in infos)
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace DearFTP.Connection.Commands
|
||||
|
||||
stream.Send(ResponseCode.FileStatusOK, "File coming.");
|
||||
|
||||
dataConnection.Authenticate();
|
||||
|
||||
if (dataConnection.IsTlsProtected && !dataConnection.IsAvailable)
|
||||
{
|
||||
stream.Send(ResponseCode.DataConnectionOpenError, "Passive mode not activated.");
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace DearFTP.Connection.Commands
|
||||
|
||||
stream.Send(ResponseCode.FileStatusOK, "Waiting file.");
|
||||
|
||||
dataConnection.Authenticate();
|
||||
|
||||
if (dataConnection.IsTlsProtected && !dataConnection.IsAvailable)
|
||||
{
|
||||
stream.Send(ResponseCode.DataConnectionOpenError, "Passive mode not activated.");
|
||||
|
||||
@@ -64,10 +64,7 @@ namespace DearFTP.Connection
|
||||
|
||||
if (IsTlsProtected)
|
||||
{
|
||||
var sslStream = new SslStream(_client.GetStream(), false);
|
||||
sslStream.AuthenticateAsServer(FtpServer.Instance.Configuration.Tls.X509Certificate, false, true);
|
||||
|
||||
Stream = sslStream;
|
||||
Stream = new SslStream(_client.GetStream(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,6 +73,14 @@ namespace DearFTP.Connection
|
||||
});
|
||||
}
|
||||
|
||||
public void Authenticate()
|
||||
{
|
||||
if (IsTlsProtected)
|
||||
{
|
||||
((SslStream)Stream).AuthenticateAsServer(FtpServer.Instance.Configuration.Tls.X509Certificate, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivateTls()
|
||||
{
|
||||
IsTlsProtected = true;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace DearFTP.Connection
|
||||
|
||||
void Create();
|
||||
void AcceptClient();
|
||||
void Authenticate();
|
||||
void ActivateTls();
|
||||
void DesactivateTls();
|
||||
void Close();
|
||||
|
||||
@@ -66,10 +66,7 @@ namespace DearFTP.Connection
|
||||
|
||||
if (IsTlsProtected)
|
||||
{
|
||||
var sslStream = new SslStream(_client.GetStream(), false);
|
||||
sslStream.AuthenticateAsServer(FtpServer.Instance.Configuration.Tls.X509Certificate, false, true);
|
||||
|
||||
Stream = sslStream;
|
||||
Stream = new SslStream(_client.GetStream(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,6 +75,14 @@ namespace DearFTP.Connection
|
||||
});
|
||||
}
|
||||
|
||||
public void Authenticate()
|
||||
{
|
||||
if (IsTlsProtected)
|
||||
{
|
||||
((SslStream)Stream).AuthenticateAsServer(FtpServer.Instance.Configuration.Tls.X509Certificate, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivateTls()
|
||||
{
|
||||
IsTlsProtected = true;
|
||||
|
||||
Reference in New Issue
Block a user