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

Socket reads with SSL delegate recv failing on osx and linux #22

Closed
na-gupta opened this issue Mar 23, 2017 · 4 comments
Closed

Socket reads with SSL delegate recv failing on osx and linux #22

na-gupta opened this issue Mar 23, 2017 · 4 comments

Comments

@na-gupta
Copy link

Socket reads with SSL delegate recv() fails on linux and mac depending on the size of the incoming data.

It looks like it has something to do with how errSSLWouldBlock/SSL_ERROR_WANT_* is handled in SSLService recv:

#if os(Linux)
    if lastError == SSL_ERROR_WANT_READ || lastError == SSL_ERROR_WANT_WRITE {
        errno = EAGAIN
        return 0
    }
#else
    if status == errSSLWouldBlock {
        errno = EWOULDBLOCK
        return Int(errSSLWouldBlock)
    }
#endif

... but in Socket readDataIntoStorage() and readDatagramIntoStorage(), it appears to be expecting delegate.recv() to throw SSLError.retryNeeded when this happens.

It appears to fails when the data is >= 4096 bytes and

  • on linux when the data is an exact multiple of 4096 (say 4096 bytes)
  • on osx when the data is NOT an exact multiple of 4096 (say 4097 bytes)
na-gupta pushed a commit to Kitura/Kitura that referenced this issue Mar 23, 2017
@shmuelk
Copy link

shmuelk commented Mar 23, 2017

Inside BlueSocket there is an internal buffer which I believe by default is 4K in size.

@na-gupta
Copy link
Author

This issue can be replicated on linux and osx using the BlueSSLService_22 branch of Kitura by running swift test -s KituraTests.TestResponse/testLargePost

@na-gupta
Copy link
Author

na-gupta commented Mar 23, 2017

@shmuelk Yes, @billabt and I were chatting about that earlier. The number of bytes that cause the failure depends on the size of that buffer, but the fix is unclear.

@billabt
Copy link
Collaborator

billabt commented Mar 25, 2017

This is fixed in v0.12.39 of BlueSocket.

@billabt billabt closed this as completed Mar 25, 2017
shmuelk pushed a commit to Kitura/Kitura that referenced this issue Mar 28, 2017
* Kitura/BlueSSLService#22 Test large gets and posts on SSL and non-SSL

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

No branches or pull requests

3 participants