Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvement: Allow writing 0 bytes to SSL socket. #6268

Closed
Timbus opened this issue Jun 26, 2018 · 0 comments
Closed

Minor improvement: Allow writing 0 bytes to SSL socket. #6268

Timbus opened this issue Jun 26, 2018 · 0 comments

Comments

@Timbus
Copy link
Contributor

Timbus commented Jun 26, 2018

Hey,
I was just patching SSL/TLS support into amqp.cr and it failed after calling socket.write() with a 0-length slice argument. The normal IO socket accepts this silently.
The error occurs in unbuffered_write:

def unbuffered_write(slice : Bytes)
check_open
count = slice.size
bytes = LibSSL.ssl_write(@ssl, slice.pointer(count), count)
unless bytes > 0
raise OpenSSL::SSL::Error.new(@ssl, bytes, "SSL_write")
end
nil
end

because openssl will return an "unexpected EOF" if count == 0. (It might also just be returning a 0, because 0 bytes are written.. IDK)

It would be nice if the behaviour was aligned with the standard socket, and it just succeeded after "writing" a 0-length buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants