Class FtpSslStream
FtpSslStream is an SslStream that properly sends a close_notify message when closing the connection. This is required per RFC 5246 to avoid truncation attacks. For more information, see https://tools.ietf.org/html/rfc5246#section-7.2.1
Inspired by: https://stackoverflow.com/questions/237807/net-sslstream-doesnt-close-tls-connection-properly/22626756#22626756
See: https://learn.microsoft.com/en-us/windows/win32/secauthn/shutting-down-an-schannel-connection See: https://learn.microsoft.com/en-us/windows/win32/secauthn/using-sspi-with-a-windows-sockets-client?source=recommendations
Note: Here is a quote from: https://github.com/dotnet/standard/issues/598#issuecomment-352148072 "The SslStream.ShutdownAsync API was added to .NET Core 2.0. It was also added to .NET Framework 4.7. Logically, since .NET Core 2.0 and .NET Framework 4.7.1 are aligned with NETStandard2.0, it could have been part of the NETStandard20 definition. But it wasn't due to when the NETStandard2.0 spec was originally designed."
Note: Microsoft says we should not override close(): "Place all cleanup logic for your stream object in Dispose(Boolean). Do not override Close()." See: https://learn.microsoft.com/en-us/dotnet/api/system.io.stream.dispose?view=net-7.0 But: We recently changed the below logic due to issue #1107, which solved the problem in part
public class FtpSslStream : SslStream, IDisposable, IAsyncDisposable
- Inheritance
-
FtpSslStream
- Implements
- Inherited Members
- Extension Methods
Constructors
FtpSslStream(Stream, bool, RemoteCertificateValidationCallback)
Create an SslStream object
public FtpSslStream(Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
Parameters
innerStream
StreamleaveInnerStreamOpen
booluserCertificateValidationCallback
RemoteCertificateValidationCallback
Methods
Close()
Close
public override void Close()
ToString()
For representing this SslStream in the log
public override string ToString()