Skip to content

Commit

Permalink
Switching to new SslProtocols
Browse files Browse the repository at this point in the history
  • Loading branch information
artiomchi committed Sep 26, 2017
1 parent 31f8b68 commit de3258a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
6 changes: 3 additions & 3 deletions FluentFTP/Client/FtpClient_Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public bool PlainTextEncryption {
#endif

#if CORE
private SslProtocols m_SslProtocols = SslProtocols.Tls11 | SslProtocols.Ssl3;
private SslProtocols m_SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
#else
private SslProtocols m_SslProtocols = SslProtocols.Default;
#endif
Expand Down Expand Up @@ -1102,7 +1102,7 @@ public virtual void Connect() {
throw new ObjectDisposedException("This FtpClient object has been disposed. It is no longer accessible.");

if (m_stream == null) {
m_stream = new FtpSocketStream();
m_stream = new FtpSocketStream(m_SslProtocols);
m_stream.ValidateCertificate += new FtpSocketStreamSslValidation(FireValidateCertficate);
} else {
if (IsConnected) {
Expand Down Expand Up @@ -1221,7 +1221,7 @@ public virtual async Task ConnectAsync()

if (m_stream == null)
{
m_stream = new FtpSocketStream();
m_stream = new FtpSocketStream(m_SslProtocols);
m_stream.ValidateCertificate += new FtpSocketStreamSslValidation(FireValidateCertficate);
}
else
Expand Down
2 changes: 1 addition & 1 deletion FluentFTP/Stream/FtpDataStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void SetPosition(long pos) {
/// Creates a new data stream object
/// </summary>
/// <param name="conn">The control connection to be used for carrying out this operation</param>
public FtpDataStream(FtpClient conn) {
public FtpDataStream(FtpClient conn) : base(conn.SslProtocols) {
if (conn == null)
throw new ArgumentException("The control connection cannot be null.");

Expand Down
34 changes: 12 additions & 22 deletions FluentFTP/Stream/FtpSocketStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace FluentFTP
/// </summary>
public class FtpSocketStream : Stream, IDisposable
{
private SslProtocols m_SslProtocols;
public FtpSocketStream(SslProtocols defaultSslProtocols)
{
m_SslProtocols = defaultSslProtocols;
}

/// <summary>
/// Used for tacking read/write activity on the socket
/// to determine if Poll() should be used to test for
Expand Down Expand Up @@ -463,7 +469,7 @@ internal async Task<int> RawSocketReadAsync(byte[] buffer)
}
#endif

#if CORE
#if ASYNC && !NET45
/// <summary>
/// Bypass the stream and read directly off the socket.
/// </summary>
Expand Down Expand Up @@ -1009,11 +1015,7 @@ public async Task ConnectAsync(string host, int port, FtpIpVersion ipVersions)
/// <param name="targethost">The host to authenticate the certificate against</param>
public void ActivateEncryption(string targethost)
{
#if CORE
ActivateEncryption(targethost, null, SslProtocols.Tls11 | SslProtocols.Ssl3);
#else
ActivateEncryption(targethost, null, SslProtocols.Default);
#endif
ActivateEncryption(targethost, null, m_SslProtocols);
}

#if ASYNC
Expand All @@ -1025,11 +1027,7 @@ public void ActivateEncryption(string targethost)
/// <param name="targethost">The host to authenticate the certificate against</param>
public async Task ActivateEncryptionAsync(string targethost)
{
#if CORE
await ActivateEncryptionAsync(targethost, null, SslProtocols.Tls11 | SslProtocols.Ssl3);
#else
await ActivateEncryptionAsync(targethost, null, SslProtocols.Default);
#endif
await ActivateEncryptionAsync(targethost, null, m_SslProtocols);
}
#endif

Expand All @@ -1042,11 +1040,7 @@ public async Task ActivateEncryptionAsync(string targethost)
/// <param name="clientCerts">A collection of client certificates to use when authenticating the SSL stream</param>
public void ActivateEncryption(string targethost, X509CertificateCollection clientCerts)
{
#if CORE
ActivateEncryption(targethost, clientCerts, SslProtocols.Tls11 | SslProtocols.Ssl3);
#else
ActivateEncryption(targethost, clientCerts, SslProtocols.Default);
#endif
ActivateEncryption(targethost, clientCerts, m_SslProtocols);
}

#if ASYNC
Expand All @@ -1059,11 +1053,7 @@ public void ActivateEncryption(string targethost, X509CertificateCollection clie
/// <param name="clientCerts">A collection of client certificates to use when authenticating the SSL stream</param>
public async Task ActivateEncryptionAsync(string targethost, X509CertificateCollection clientCerts)
{
#if CORE
await ActivateEncryptionAsync(targethost, clientCerts, SslProtocols.Tls11 | SslProtocols.Ssl3);
#else
await ActivateEncryptionAsync(targethost, clientCerts, SslProtocols.Default);
#endif
await ActivateEncryptionAsync(targethost, clientCerts, m_SslProtocols);
}
#endif

Expand Down Expand Up @@ -1250,7 +1240,7 @@ public async Task AcceptAsync()
}
#endif

#if CORE
#if ASYNC && !NET45
/// <summary>
/// Accepts a connection from a listening socket
/// </summary>
Expand Down

0 comments on commit de3258a

Please sign in to comment.