[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] No data flowing in bufferevent_openssl_filter_new



Hi,

I am rather new to libevent and I am doing the following in a smaller server application:
 - Create an event loop listening for connections on a given port.
 - If the first data sent by the client looks like an SSL client Hello, switch the
   connection to ssl, by installing a filter.
 - process data as ususal (simply echo it)

When connecting to the server with telnet, all is working. When connecting to the
server with the openssl s_client, I do get a successful SSL handshake, but after that,
I can only write data to the server and never get anything back, and debug output
shows, that clientRead is never called. What am I doing wrong?

This is the read callback installed by bufferevent_setcb:

static void clientInitialRead(struct bufferevent *bev, void *arg)
{
	connState_t *conn = arg;
	struct evbuffer *evi = bufferevent_get_input(bev);
	struct evbuffer_iovec cont;
	struct bufferevent *bevSsl;

	evbuffer_peek(evi, -1, NULL, &cont, 1);
	if (isSslClientHello(&cont, conn)) {
		bevSsl = bufferevent_openssl_filter_new(conn->global->mainEvents,
		  bev, conn->ssl, BUFFEREVENT_SSL_ACCEPTING, BEV_OPT_DEFER_CALLBACKS);
		if (!bevSsl) {
			PA_WARNING("Error creating SSL filter bev");
			return;
		}
		conn->bev = bevSsl;
		bufferevent_setcb(bevSsl, clientRead, clientWrite, clientEvent, conn);
		bufferevent_setwatermark(bevSsl, EV_READ, 0, 16348);
		bufferevent_enable(bevSsl, EV_READ|EV_WRITE);
	} else {
		clientRead(bev, arg);
	}
}

And this is the "normal" read callback:

static void clientRead(struct bufferevent *bev, void *arg)
{
	connState_t *conn = arg;
	struct evbuffer *evi = bufferevent_get_input(bev);
	struct evbuffer *evo = bufferevent_get_output(bev);

	evbuffer_remove_buffer(evi, evo, evbuffer_get_length(evi));
}


-- 
Nils Rennebarth
Software Developer
Teldat packetalarm logo
Teldat Security GmbH
Moenchhaldenstr. 28
D-70191 Stuttgart
Tel: +49 711 900300 - 62
Fax: +49 711 900300 - 90
E-Mail: nils.rennebarth@xxxxxxxxx

Location: GmbH Nuernberg, Local Court Nuernberg, HRB 25481 Managing Director: Bernd Buettner

Teldat packetalarm banner

--------------------------------
The information contained in this e-mail has been carefully researched, but the possibility of it being inapplicable in individual cases cannot be ruled out. We therefore regret that we cannot accept responsibility or liability of any kind whatsoever for the correctness of the information given. Please notify us if you discover that information is inapplicable.

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.