Can anyone give me a code sample of how to use non-blocking bio with OpenSSL?

View: New views
3 Messages — Rating Filter:   Alert me  

Can anyone give me a code sample of how to use non-blocking bio with OpenSSL?

by Sabyasachi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am writing an application where I'll need to use non-blocking bio with OpenSSL.
I create the socket myself using "socket", and supply it to the BIO by:
    bio = BIO_new_socket(sock)

And then I pass that bio to the SSL context using:
    SSL_set_bio (stream->con,bio,bio);

I have searched a lot to find the proper way of doing non-blocking SSL IO, but could not find anything in detail.

Can anyone give me a proper code snippet of how to do non-blocking SSL IO? Any pointer to such information?

--
Sabyasachi

Re: Can anyone give me a code sample of how to use non-blocking bio with OpenSSL?

by tomt-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I also focus on it, And it seem openssl don't support nonblocking socket,although we can set fd nonblocking.

Hope the view above is incorrect.

Re: Can anyone give me a code sample of how to use non-blocking bio with OpenSSL?

by Sebastián Treu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Nov 5, 2009 at 11:46 AM, Sabyasachi Ruj <ruj.sabya@...> wrote:

> I am writing an application where I'll need to use non-blocking bio with
> OpenSSL.
> I create the socket myself using "socket", and supply it to the BIO by:
>     bio = BIO_new_socket(sock)
> And then I pass that bio to the SSL context using:
>     SSL_set_bio (stream->con,bio,bio);
> I have searched a lot to find the proper way of doing non-blocking SSL IO,
> but could not find anything in detail.
> Can anyone give me a proper code snippet of how to do non-blocking SSL
> IO? Any pointer to such information?
> --
> Sabyasachi
>

Hi,

I use non-blocking file descriptors for that. I don't know if this is
the method, but i set the fd to O_NONBLOCK and then re-read the error
from ERR_get_error().

Just as an example:

http://pastebin.com/m7b684078

Regards,
--
If you want freedom, compile the source. Get gentoo.

Sebastián Treu
http://labombiya.com.ar
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@...
Automated List Manager                           majordomo@...