0

While searching for an answer to this question I found this sample code which looks like just what I need except it calls

select_wait()

which is defined in non_blocking.h but which is otherwise unlocatable.

Is select_wait() proprietary code? Is it an entrypoint in some DLL I can get? How do I duplicate whatever select_wait() does? Does it look safe to simply ignore select_wait() and immediately retry the BIO_read/write calls?

Update: In testing the code, the select_wait() appears necessary because BIO_read will hang if input isn't available. However, RSA's sample code does at most one successful BIO_read before breaking out of the for-loop, so their code also would fail to accept a POST from Chrome as described in the original question.

Community
  • 1
  • 1

2 Answers2

0

Apparently it's part of the proprietary BSAFE library/framework

keks
  • 189
  • 5
  • Apparently so, and probably equivalent to BIO_get_fd(bio_con, sock), fd_zero(fdset), fd_set(sock, fdset), select(...). However, the sample code doesn't work with Chrome POSTs because BIO_read needs to be called more than once. – Witness Protection ID 44583292 Aug 15 '11 at 18:50
0

If you have a socket handle, use select() WinSock API function.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • I think that mixing `select()` and `BIO_read()` may lead to highly confusing results. should be fine if using the lower level `SSL_read` etc though, provided you can handle the extra complexity. – Hasturkun Aug 14 '11 at 18:21
  • @Eugene: I don't think there's any correlation between select() and what's ready to read from the SSL buffers. I going to try the code without select_wait() and see what happens. – Witness Protection ID 44583292 Aug 14 '11 at 18:59
  • @Eugene: I take that back. The Openssl BIO_should_retry page says: "one solution is to use non blocking I/O and use a timeout on the select() (or equivalent) call." I'll give it a try. – Witness Protection ID 44583292 Aug 14 '11 at 23:43
  • @mike Correct, there could be decrypted buffered plaintext ready to read without blocking, so calling select() could block you unnecessarily. – user207421 Aug 16 '11 at 01:05
  • @Eugene: And yet SSL servers seem to often rely on select(). I'm thinking it most be possible to hang most SSL servers with ill-formed requests. – Witness Protection ID 44583292 Aug 16 '11 at 02:02
  • @mike I don't know how OpenSSL implements this. In general, there's a timeout for socket operations in each server, so the thread won't wait forever anyway. And you don't need to use SSL to send a half of request to the server and wait. This is how some DDOS attacks work. – Eugene Mayevski 'Callback Aug 16 '11 at 08:55