bentonstark / starksoft-aspen

.net / mono security and cryptography library that provides client support for ftps, gnupg, smartcard, and socks / http proxies
106 stars 49 forks source link

FTPS with TLS 1.2 #27

Closed Sappharad closed 7 years ago

Sappharad commented 7 years ago

Hello,

While testing this library against a bunch of FTP servers to see if I could use it for a project at work to replace FtpWebRequest, I encountered a server that it refused to connect to.

The reason was that the server was only allowing TLS 1.2 connections. The SSLStream class that you're using supports TLS 1.2, but that wasn't added until .NET 4.5 and your code here appears to target .NET 4.0. I updated the code locally to .NET 4.5 and confirmed that switching SslProtocols.Tls to SslProtocols.Tls12 allowed the server in question to connect successfully. I basically just replaced the existing TLS option with TLS12 since it's backwards compatible anyway. I noticed the FileZilla FTP client seems to only support TLS now, so it seemed reasonable for me to only support TLS where I wanted to use this too.

I've created a fork with the changes I'll be using. Would you like a pull request for the .NET 4.5 update and the TLS upgrade? I see that you considered a .NET 4.5 upgrade to be a downside in a previous Issue, so I'm not sure if you want this yet.

TLS changes are this commit: https://github.com/Sappharad/starksoft-aspen/commit/9d2d3c918eb02c2ea3ef8fda8c707126b01ef89d (.NET upgrade is the prior commit, unit tests the following one)

Thanks, Paul

bentonstark commented 7 years ago

Thanks Paul for the update offer. I can use the diff you provided to make the changes. .NET 4.5 isn't an issue as long as I can use .NET pre-compiler directives to provide optional compatibility to previous versions back to .NET 2.0. In another issue the user suggested moving to a .NET 4.5 specific construct for doing threading but that would mean breaking all backwards compatibility which I don't think would be the right move for this library.

Thanks! Benton

bentonstark commented 7 years ago

Added support for TLS 1.1 and TLS 1.2 (requires .NET / Mono 4.5+) https://github.com/bentonstark/starksoft-aspen/commit/d220aa05f487c8e57d87d9c12ea94361b411f67a