I am using OpenSSL 1.0.0-fips on Linux. The issue I am having is that SSL_connect() is returning -1 and SSL_get_error() is returning SSL_ERROR_WANT_READ. I then put the file descriptor into a select() with a timeval structure set to 10 seconds and the select() just times out.
I fired up Wireshark and I see the "Client Hello" go out and I see the ServerHello come back to the client but it never "wakes up" in the select(). It just times out.
My questions are:
Do I have to create a BIO object using
BIO_new_socket()and then assign the BIO object to my SSL object usingSSL_set_bio()? The man page forSSL_set_fd()says it will automatically create a BIO object so that seems to imply thatSSL_set_bio()is sort of a useless function that you never really have to call.Let us say we use
SSL_set_fd()and assign a connected TCP file descriptor that is blocking. Let us say that we then later change that file descriptor to non-blocking usingfcntl(). Does this break the SSL object (or the underlying BIO object) in anyway?
apps/ocsp.cto see how OpenSSL does it. I seem to recall a normal context is setup in blocking mode, then things switch to non-blocking mode using the underlying socket. Search for code that callsBIO_get_fdandselect. AFAIK, its the only example of non-blocking I/O in the self documenting code :) - jww