View Issue Details

IDProjectCategoryView StatusLast Update
0000054LDMud 3.3Runtimepublic2004-07-01 22:23
Reporterlynx Assigned Tolars 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Summary0000054: TLS doesn't work without pthreads
Descriptionwhen compiling the driver with gnutls and
without pthreads, tls_init_connection throws
a tls_error that says:

"Function was interrupted."

Everything works when using pthreads, but pthreads may
not be safe.
TagsNo tags attached.

Activities

fippo

2004-04-27 13:15

reporter   ~0000052

http://www.gnu.org/software/gnutls/documentation/gnutls/gnutls.html#gnutls_handshake

The non-fatal errors such as GNUTLS_E_AGAIN and GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which should be later be resumed. Call this function again, until it returns 0

See attached patch.

configure-skript seems to auto-add pthreads dependency for ssl. I guess because of this bug. Would be nice if you removed that.

lg

fippo

2004-04-27 13:21

reporter   ~0000053

mh... unintuitive file upload... as its a threeliner (pkg-tls.c)
566c566,568
< ret = gnutls_handshake(ip->tls_session);
---
> do {
> ret = gnutls_handshake(ip->tls_session);
> } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);

fippo

2004-04-27 14:08

reporter   ~0000054

Looks like openssl has the same problem (line 548)
http://www.openssl.org/docs/ssl/SSL_do_handshake.html
being called only once.

lynx

2004-04-27 15:42

reporter   ~0000056

Last edited: 2004-04-27 15:43

Ok, so fippo fixed gnutls to run without pthreads. Very cool.
Now out of perfectionism let's try to get openssl to work.
Whenever we connect by SSL it aborts with this message:

  error:00000001::lib(0) :func(0) :reason(1)

I tried some changes that may fix the handshaking, but so
far the behaviour has not changed. Here's my change:

        do {
            if ((n = SSL_do_handshake(session)) < 0)
                ret = - SSL_get_error(session, n);
            else
                ret = 0;
        } while (ret == SSL_ERROR_WANT_READ || ret == SSL_ERROR_WANT_WRITE);

        if (n < 0) {
            SSL_free(session);
            break;
        }

The documentation mentions something wanting to be read or written,
but we have nothing to read or write.. do we?

edited on: 04-27-04 17:43

lars

2004-04-28 22:14

reporter   ~0000057

Thanks for the analysis!

I have implemented both the GnuTLS as well as the OpenSSL patch in 3.3.536. The reason why the original OpenSSL patch didn't work was probably because 'ret' was assigned the negated error code, but then compared to the un-negated error code constant - my implementation fixed that.

I couldn't reproduce the TLS->pthreads dependency in configure, and looking at the configure code I don't see one either.

Issue History

Date Modified Username Field Change
2004-04-27 11:53 lynx New Issue
2004-04-27 13:15 fippo Note Added: 0000052
2004-04-27 13:21 fippo Note Added: 0000053
2004-04-27 14:08 fippo Note Added: 0000054
2004-04-27 15:42 lynx Note Added: 0000056
2004-04-27 15:43 lynx Note Edited: 0000056
2004-04-28 22:14 lars Status new => resolved
2004-04-28 22:14 lars Resolution open => fixed
2004-04-28 22:14 lars Assigned To => lars
2004-04-28 22:14 lars Note Added: 0000057
2004-07-01 22:23 lars Status resolved => closed