Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send close-notify to client on a TLS Session using SslStream

I'm trying to create a custom FTP server with TcpListener over SSL.

When closing the connections the client generates an error because when the socket gets shutdown is not sending close-notify alert. Which I have read is not considered in .NET TLS implementation.

What would be the best way to add this behavior to my server. How do I send this alert? Is it simple as writing the string to the SSL stream or wrapped stream.

I would appreciate if someone can point me in the right direction.

Thanks

like image 840
Arturo Martinez Avatar asked Oct 07 '22 09:10

Arturo Martinez


2 Answers

I found that SslStream just simply does not support this, so the only alternative I see at this moment is to send it manually. It is what I would call "manual sunset".

I posted my code here (since it was the most earliest mentioning of the problem I could find). Please have a look and advise if it helps you.

I hope Microsoft will find time to fix it in next versions of the framework.

like image 175
Neco Avatar answered Oct 13 '22 11:10

Neco


close-notify should be sent automatically by the SSL layer when you close the socket, if you were the end that closed first. If you were the end that received EOS and so you are closing in response, RFC 2246 allows for close-notify not to be sent in response.

You can't send it yourself.

like image 22
user207421 Avatar answered Oct 13 '22 10:10

user207421