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