[openssl-users] ssl_pending returns 0 despite having data to read

Nadia Lapkovskaya nadia at yaymedia.com
Wed Jan 11 20:07:43 UTC 2017


Hi,

We are using openssl-1.0.2j. Noticed, that for http protocol everything is working fine, but when we are using our own binary protocol ssl_pending returns 0 all the time. We are using blocking socket. Tried with SSL_CTX_set_read_ahead set and unset.

Out test server sends back any info received from the client.

Test code looks like this:
bool write(const uint64_t* data, int count)
{
  int rc = SSL_write(_ssl, data, count * sizeof(uint64_t));
  return rc > 0 ? true : false;
}

bool read(uint64_t* data, int count)
{
  do {
      int rc = SSL_read(_ssl, data, count * sizeof(uint64_t));
      if (rc <= 0) {
          int err = SSL_get_error(_ssl, rc);
          std::string errs = ERR_error_string(err, nullptr);
          return false;
      }
  } while (SSL_pending(_ssl));
  return true;
}

During first ssl_read we received eight bytes, and after that ssl_pending returns 0. If we continue reading despite having no pending data, ssl_read returns the rest of the data. 
Could you please suggest what is wrong here.


Best regards,
Nadia.



More information about the openssl-users mailing list