make SSL_shutdown work with non-blocking BIOs

2009-04-07 Thread Darryl Miles
With the announcement of OpenSSL 1.0.0 on the way, may I attempt to get some attention on this issue for which: * a patch exists * a test case exists (that exposes the problem, that verifies the fix doesn't break anything) * multiple users have shared their concern over the years (some

Re: make SSL_shutdown work with non-blocking BIOs

2009-04-07 Thread Dr. Stephen Henson
On Tue, Apr 07, 2009, Darryl Miles wrote: With the announcement of OpenSSL 1.0.0 on the way, may I attempt to get some attention on this issue for which: * a patch exists * a test case exists (that exposes the problem, that verifies the fix doesn't break anything) * multiple users

Re: make SSL_shutdown work with non-blocking BIOs

2007-11-13 Thread Thor Lancelot Simon
On Mon, Oct 01, 2007 at 08:06:04PM +0100, Darryl Miles wrote: Would Davide be so kind as to look over the following openssl-dev list post for the semantics I suggest and confirm that logic would work for him: http://marc.info/?l=openssl-devm=115153998821797w=2 The archive at marc.info

Re: make SSL_shutdown work with non-blocking BIOs

2007-11-12 Thread Darryl Miles
Try next_in_thread, take a look at the thread views (by clicking the subject line) you get to: http://marc.info/?t=11515400401r=1w=2 For background reading see also the threads: http://marc.info/?l=openssl-usersm=115088475305680w=2 http://marc.info/?t=11509972822r=1w=2

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-15 Thread Nanno Langstraat
Darryl Miles wrote: Nanno Langstraat wrote: So I can add one more voice to the choir: the current SSL_shutdown() API appears to give trouble to every non-blocking developer (I remember I lost serious time noticing + tracking down this 100% CPU bug), and afterwards things still don't really

RE: make SSL_shutdown work with non-blocking BIOs

2007-10-15 Thread David Schwartz
This goes pear-shaped as follows: * The SSL connection is made and used * The remote side closes its file descriptor (e.g. process killed, TCP shutdown(RD)) * Local SSL_read() returns 0. The app event loop sets a flag and makes sure it never calls SSL_read() again.

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-15 Thread Darryl Miles
Nanno Langstraat wrote: It turns out that the problem does *not* directly involve SSL_shutdown(), but it *is* attributable to OpenSSL, and specifically OpenSSL's non-blocking shutdown semantics. Okat thats cleared that up, it is indeed unrelated to the OP of this thread. Please move replies

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-15 Thread Nanno Langstraat
David Schwartz wrote: This goes pear-shaped as follows: The application is broken. Once SSL_read returns 0, the connection is dead. Quote chapter and verse of the OpenSSL API documentation, or desist from such vehement statements. You can not scold an API user for violating rules

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-15 Thread Darryl Miles
Nanno Langstraat wrote: David Schwartz wrote: The socket is not and never again will be readable. It's passed on. It's bereft of life. It's not pinin' for the fjords. Etc. And more importantly, OpenSSL is the only party who knows this underlying cause, and SSL_want_read() is the designated

RE: make SSL_shutdown work with non-blocking BIOs

2007-10-15 Thread David Schwartz
Nanno Langstraat: Quote chapter and verse of the OpenSSL API documentation, or desist from such vehement statements. You can not scold an API user for violating rules that are not in the documentation. I already claimed that the application programmer is not given the knowledge that this

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-11 Thread Nanno Langstraat
Darryl Miles wrote: David Schwartz wrote: If I'm misunderstanding the man page and/or the source code please speak up. My man page says: If the underlying BIO is non-blocking, SSL_shutdown() will also Yes but what SSL_shutdown() actually does is always return 0 This discussion a

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-11 Thread Darryl Miles
Nanno Langstraat wrote: So I can add one more voice to the choir: the current SSL_shutdown() API appears to give trouble to every non-blocking developer (I remember I lost serious time noticing + tracking down this 100% CPU bug), and afterwards things still don't really work right. I can't

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-11 Thread Darryl Miles
Darryl Miles wrote: 2) SSL_read() already has a return value -1/ZERO_RETURN which indicates end-of-stream. You may then call SSL_shutdown() to look to see if 1 is returned or not. Or even SSL_get_shutdown() and take whatever security action your application needs to take in the event of an

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-02 Thread Davide Libenzi
On Mon, 1 Oct 2007, Richard Salz wrote: If that's an example of working API for someone, it's no surprise websphere blows. There's no need to be rude. And WebSphere doesn't use OpenSSL. It was not me that showed up throwing titles, an sigs to look up. I tried to keep the conversation

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Darryl Miles
What is the difference between this an my patch from a year or so ago ? http://marc.info/?t=11509972822r=1w=2 '[PATCH] Fix for SSL_shutdown() with non-blocking not returning -1' http://marc.info/?t=11515400401r=1w=2 '[PATCH2] Fix for SSL_shutdown() with non-blocking not returning

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Darryl Miles
Davide Libenzi wrote: On Sat, 29 Sep 2007, Richard Salz wrote: I seriously doubt ppl are using SSL_shutdown() with non-blocking BIOs, together with the current API semantics. Seriously. Are you new here? This library has been around for more than a decade. There are *lots* of people using

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Darryl Miles
Richard Salz wrote: double/triple check over it). Whatever fix you guys come up with, as long as SSL_shutdown() ends up having sane (somehow aligned to SSL_read, SSL_write, etc...) semantics WRT non-blocking BIOs. Nope. Maybe a new shutdown that has your semantics, but do not break

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Davide Libenzi
On Mon, 1 Oct 2007, Darryl Miles wrote: The Are you new here? I find somewhat offputting, even through it was not directed at me. Richard is obviously old here and set in his ways and thinks that his OpenSSL library is better than it actually is. Oh, don't worry about that ;) I'm used to ml

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Davide Libenzi
On Mon, 1 Oct 2007, Darryl Miles wrote: Richard Salz wrote: double/triple check over it). Whatever fix you guys come up with, as long as SSL_shutdown() ends up having sane (somehow aligned to SSL_read, SSL_write, etc...) semantics WRT non-blocking BIOs. Nope. Maybe a new

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Darryl Miles
Davide Libenzi wrote: Can this be worked around? Sure. With some woodoo/ugly magic code in the async status code handling. You *cannot* always wait for readwrite, since you'll be exiting the event selection loop immediately, every time. You need to bolt-in the shutdown logic *outside* the

RE: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread David Schwartz
If I'm misunderstanding the man page and/or the source code please speak up. My man page says: If the underlying BIO is non-blocking, SSL_shutdown() will also return when the underlying BIO could not satisfy the needs of SSL_shutdown() to continue the handshake. In this

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Darryl Miles
David Schwartz wrote: If I'm misunderstanding the man page and/or the source code please speak up. My man page says: If the underlying BIO is non-blocking, SSL_shutdown() will also return when the underlying BIO could not satisfy the needs of SSL_shutdown() to continue

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Davide Libenzi
On Mon, 1 Oct 2007, Darryl Miles wrote: Davide Libenzi wrote: Can this be worked around? Sure. With some woodoo/ugly magic code in the async status code handling. You *cannot* always wait for readwrite, since you'll be exiting the event selection loop immediately, every time. You need to

Re: make SSL_shutdown work with non-blocking BIOs

2007-10-01 Thread Richard Salz
If that's an example of working API for someone, it's no surprise websphere blows. There's no need to be rude. And WebSphere doesn't use OpenSSL. /r$ -- STSM, DataPower Chief Programmer Websphere DataPower SOA Appliances http://www.ibm.com/software/integration/datapower/

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-30 Thread Richard Salz
Wait for both, keep your own state. Works well enough. See the products at the URL in my .sig for proof :) /r$ -- STSM, DataPower Chief Programmer Websphere DataPower SOA Appliances http://www.ibm.com/software/integration/datapower/

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-30 Thread Davide Libenzi
On Sun, 30 Sep 2007, Richard Salz wrote: Wait for both, keep your own state. Works well enough. See the products at the URL in my .sig for proof :) Wow! That *really* impressed me. So, besides throwing titles and sigs, can you show how easily can you cope with the current SSL_shutdown()

make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Davide Libenzi
Would it be possible to make SSL_shutdown() on non-blocking BIOs, conform to the documentation and aligned to SSL_read, SSL_write, ...? http://www.openssl.org/docs/ssl/SSL_shutdown.html I cooked a tentative patch below, that seems to be working here. It definitely need double check from someone

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Thor Lancelot Simon
On Sat, Sep 29, 2007 at 01:19:38PM -0700, Davide Libenzi wrote: But that code *never* returns WANT_READ/WANT_WRITE. Non blocking sockets always get SSL_ERROR_SYSCALL. Well, unless the case where they both succeed immediately - but that's like blocking behaviour. Yes, I'm well aware of

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Davide Libenzi
On Sat, 29 Sep 2007, Thor Lancelot Simon wrote: As far as changes to the existing behaviour, blocking BIOs will never get the new error code (0). And noone could have used the non-blocking BIOs in a sane way, with the current behavior (lack of proper WANT_READ/WANT_WRITE). I'm sorry,

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Thor Lancelot Simon
On Sat, Sep 29, 2007 at 03:11:18PM -0700, Davide Libenzi wrote: Heh? Wait for readwrite? Consider such code: for (;;) { err = SSL_shutdown(); code = SSL_get_error(ssl, err); if (code == SSL_ERROR_SYSCALL) {

RE: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread David Schwartz
Thor Simon wrote: On Sat, Sep 29, 2007 at 03:11:18PM -0700, Davide Libenzi wrote: Heh? Wait for readwrite? Consider such code: for (;;) { err = SSL_shutdown(); code = SSL_get_error(ssl, err); if (code == SSL_ERROR_SYSCALL) {

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Davide Libenzi
On Sat, 29 Sep 2007, Thor Lancelot Simon wrote: On Sat, Sep 29, 2007 at 03:11:18PM -0700, Davide Libenzi wrote: Heh? Wait for readwrite? Consider such code: for (;;) { err = SSL_shutdown(); code = SSL_get_error(ssl, err); if (code ==

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Thor Lancelot Simon
On Sat, Sep 29, 2007 at 03:35:29PM -0700, Davide Libenzi wrote: I seriously doubt ppl are using SSL_shutdown() with non-blocking BIOs, together with the current API semantics. Seriously. Well, how do you suppose they're terminating their SSL sessions? If you look at the archive of this

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Davide Libenzi
On Sat, 29 Sep 2007, Thor Lancelot Simon wrote: On Sat, Sep 29, 2007 at 03:35:29PM -0700, Davide Libenzi wrote: I seriously doubt ppl are using SSL_shutdown() with non-blocking BIOs, together with the current API semantics. Seriously. Well, how do you suppose they're terminating their

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Richard Salz
I seriously doubt ppl are using SSL_shutdown() with non-blocking BIOs, together with the current API semantics. Seriously. Are you new here? This library has been around for more than a decade. There are *lots* of people using the current API with non-blocking. Seriously. double/triple

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Davide Libenzi
On Sat, 29 Sep 2007, Richard Salz wrote: I seriously doubt ppl are using SSL_shutdown() with non-blocking BIOs, together with the current API semantics. Seriously. Are you new here? This library has been around for more than a decade. There are *lots* of people using the current API

Re: make SSL_shutdown work with non-blocking BIOs

2007-09-29 Thread Richard Salz
Define elegantly. The current API works. Better is not a reason to change it. /r$ -- STSM, DataPower Chief Programmer Websphere DataPower SOA Appliances http://www.ibm.com/software/integration/datapower/ __ OpenSSL