I have written one SSL client using OpenSSL APIs to interact with one SSL server. In OpenSSL site I learned that write buffer needs to be flushed after writing some data. I am using SSL_Write and SSL_Read in my client program. As OpenSSL site suggested I tried to flush the data using BIO_flush(BIO* ), I am getting crash here.
I am using the SSL libraries got from this site
Here I am not clear about whether BIO_flush flashes the read buffer or write buffer..:-( So I just wanted to know is there any other ways to flush the SSL write buffer...?
Here is the details about my client program.
- Creating SSL object(mSsl) using SSL_new
- Creating a TCP socket and making connection with server
- Creating BIO object(mBio) using BIO_new_socket(socket_id,BIO_NOCLOSE)
- Setting the BIO object to SSL object using SSL_set_bio(mSsl,mBio,mBio);
- Setting the socket to SSL object using SSL_set_fd(mSsl,socket_id);
- Making SSL connection with server using SSL_Connect(mSsl);
After the above steps I am starting two separate threads for write and read. Write thread uses SSL_write to write the data to server and Read thread uses SSL_Read to read the data from the server.
In Write thread after writing each packet using SSL_Write I am calling BIO_flush(mBio).
In whole program I am directly using mBio object only in this place for doing bio buffer flush.
When I do start sending the some packets, program in crashing in BIO_flush... As per the dump says its in BIO_ctrl function. I am not getting anything more than that.
Did any one used the library which I have provided link above and facing the same problem.. ? If yes please let me know if you know the solution.
Is there any thread synchronization rules to use BIO_flush()...? I mean call to BIO_flush SSL_Read should not happen at the same time like that... ?