[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] bufferevent with openssl server
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] bufferevent with openssl server
- From: Wayne Shao <wshao99@xxxxxxxxx>
- Date: Wed, 2 Feb 2011 11:27:55 -0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Wed, 02 Feb 2011 14:28:05 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=SfC5Jwxz21kbI0twqS0rYiC/zpL10wWqIzXYqkM8kcg=; b=gsAxBidy3K+Sln3gyTA0SXlpLTfEwzGRDlJ8M2HvYdyCK9ldku9o2jSW2Jle30JN4x xx6oogZWMJT/k22xWv3qtTnSuroTHO8KuUzOnPEY/K5JnNoA9fyfBwC/4H/BUMlD7S1q Elr23Bi2i6Xzxrl7VKzdOaLa6xo7EvED4sgcQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=H3eumAPjXVp6OiwTR/76B3zo8hjs9+hvpQXtimBy1fkB4Dg14KBgd/Imdy7Z5JiGQU QBMWOVTHtMrn63fc5ewUDLBYqUKxrEtjN3DyZhQpvrHstiRZEjBm3GFVgexjyAnBZT28 VmwJkNB1QvxVg8CnRuivboA0pQVsHip6zfBbI=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi,
I tried to setup an SSL server with libevent. But the read/write callbacks are not invoked after the handshake phase.
Please see the code below.
Thanks,
W Shao
The listener callback is as follows:
void listener_cb(struct evconnlistener *listener, evutil_socket_t fd,
struct sockaddr *sa, int socklen, void *user_data) {
struct event_base *base = (struct event_base*) user_data;
struct bufferevent *bev;
BIO *sbio=BIO_new_socket(fd,BIO_NOCLOSE);
ssl=SSL_new(ctx);
SSL_set_bio(ssl,sbio,sbio);
bev = bufferevent_openssl_socket_new(base, fd, ssl, BUFFEREVENT_SSL_ACCEPTING,
BEV_OPT_CLOSE_ON_FREE);
if (!bev) {
fprintf(stderr, "Error constructing bufferevent!");
event_base_loopbreak(base);
return;
}
// Question:
// Do I need to call SSL_accept at some point?
bev = bufferevent_openssl_filter_new(base,
bev,
ssl,
BUFFEREVENT_SSL_OPEN,
BEV_OPT_CLOSE_ON_FREE);
if (!bev) {
perror("Bufferevent_openssl_new");
}
bufferevent_setcb(bev, readcb, writecb, eventcb, NULL);
bufferevent_enable(bev, EV_WRITE);
bufferevent_enable(bev, EV_READ);
}