libevent  2.2.1
Event notification library
Macros | Typedefs | Enumerations | Functions
bufferevent_ssl.h File Reference

OpenSSL support for bufferevents. More...

#include <event2/visibility.h>
#include <event2/event-config.h>
#include <event2/bufferevent.h>
#include <event2/util.h>

Go to the source code of this file.

Macros

#define BUFFEREVENT_SSL_BATCH_WRITE   2
 Control writes in the SSL bufferevents. More...
 
#define BUFFEREVENT_SSL_DIRTY_SHUTDOWN   1
 Control how to report dirty SSL shutdowns. More...
 

Typedefs

typedef struct mbedtls_ssl_context mbedtls_dyncontext
 

Enumerations

enum  bufferevent_ssl_state { BUFFEREVENT_SSL_OPEN = 0, BUFFEREVENT_SSL_CONNECTING = 1, BUFFEREVENT_SSL_ACCEPTING = 2 }
 The state of an SSL object to be used when creating a new SSL bufferevent.
 

Functions

EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_mbedtls_error (struct bufferevent *bev)
 Return the most recent MbedTLS error reported on an SSL bufferevent.
 
EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_openssl_error (struct bufferevent *bev)
 Return the most recent OpenSSL error reported on an SSL bufferevent.
 
EVENT2_EXPORT_SYMBOL void bufferevent_mbedtls_dyncontext_free (mbedtls_dyncontext *ctx)
 Deallocate heap-based MbedTLS context.
 
EVENT2_EXPORT_SYMBOL mbedtls_dyncontext * bufferevent_mbedtls_dyncontext_new (struct mbedtls_ssl_config *conf)
 Create a new heap-based MbedTLS context for use it in bufferevent_mbedtls_* functions.
 
EVENT2_EXPORT_SYMBOL struct buffereventbufferevent_mbedtls_filter_new (struct event_base *base, struct bufferevent *underlying, mbedtls_dyncontext *ssl, enum bufferevent_ssl_state state, int options)
 Create a new SSL bufferevent to send its data over another bufferevent. More...
 
EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_get_allow_dirty_shutdown (struct bufferevent *bev)
 Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag. More...
 
EVENT2_EXPORT_SYMBOL struct mbedtls_ssl_context * bufferevent_mbedtls_get_ssl (struct bufferevent *bufev)
 Return the underlying mbedtls SSL * object for an SSL bufferevent.
 
EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_renegotiate (struct bufferevent *bev)
 Tells a bufferevent to begin SSL renegotiation.
 
EVENT2_EXPORT_SYMBOL void bufferevent_mbedtls_set_allow_dirty_shutdown (struct bufferevent *bev, int allow_dirty_shutdown)
 Set value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag. More...
 
EVENT2_EXPORT_SYMBOL struct buffereventbufferevent_mbedtls_socket_new (struct event_base *base, evutil_socket_t fd, mbedtls_dyncontext *ssl, enum bufferevent_ssl_state state, int options)
 Create a new SSL bufferevent to send its data over an SSL * on a socket. More...
 
EVENT2_EXPORT_SYMBOL struct buffereventbufferevent_openssl_filter_new (struct event_base *base, struct bufferevent *underlying, struct ssl_st *ssl, enum bufferevent_ssl_state state, int options)
 Create a new SSL bufferevent to send its data over another bufferevent. More...
 
EVENT2_EXPORT_SYMBOL int bufferevent_openssl_get_allow_dirty_shutdown (struct bufferevent *bev)
 Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag. More...
 
EVENT2_EXPORT_SYMBOL struct ssl_st * bufferevent_openssl_get_ssl (struct bufferevent *bufev)
 Return the underlying openssl SSL * object for an SSL bufferevent.
 
EVENT2_EXPORT_SYMBOL void bufferevent_openssl_set_allow_dirty_shutdown (struct bufferevent *bev, int allow_dirty_shutdown)
 Set value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag. More...
 
EVENT2_EXPORT_SYMBOL struct buffereventbufferevent_openssl_socket_new (struct event_base *base, evutil_socket_t fd, struct ssl_st *ssl, enum bufferevent_ssl_state state, int options)
 Create a new SSL bufferevent to send its data over an SSL * on a socket. More...
 
EVENT2_EXPORT_SYMBOL int bufferevent_ssl_renegotiate (struct bufferevent *bev)
 Tells a bufferevent to begin SSL renegotiation.
 

Detailed Description

OpenSSL support for bufferevents.

Macro Definition Documentation

◆ BUFFEREVENT_SSL_BATCH_WRITE

#define BUFFEREVENT_SSL_BATCH_WRITE   2

Control writes in the SSL bufferevents.

By default SSL bufferevent will peek bytes from the buffer as the arrived. with respect to the segment boundaries in the buffer. However, by ignoring these segment boundaries number of packets to send can be decreased.

This flags will ignore the segment boundaries.

Useful in conjunction with http layer.

◆ BUFFEREVENT_SSL_DIRTY_SHUTDOWN

#define BUFFEREVENT_SSL_DIRTY_SHUTDOWN   1

Control how to report dirty SSL shutdowns.

If the peer (or the network, or an attacker) closes the TCP connection before closing the SSL channel, and the protocol is SSL >= v3, this is a "dirty" shutdown. If BUFFEREVENT_SSL_DIRTY_SHUTDOWN is not set (default), this is reported as BEV_EVENT_ERROR.

If instead BUFFEREVENT_SSL_DIRTY_SHUTDOWN is set, a dirty shutdown is reported as BEV_EVENT_EOF.

(Note that if the protocol is < SSLv3, you will always receive BEV_EVENT_EOF, since SSL 2 and earlier cannot distinguish a secure connection close from a dirty one. This is one reason (among many) not to use SSL 2.)

Function Documentation

◆ bufferevent_mbedtls_filter_new()

EVENT2_EXPORT_SYMBOL struct bufferevent* bufferevent_mbedtls_filter_new ( struct event_base base,
struct bufferevent underlying,
mbedtls_dyncontext *  ssl,
enum bufferevent_ssl_state  state,
int  options 
)

Create a new SSL bufferevent to send its data over another bufferevent.

Parameters
baseAn event_base to use to detect reading and writing. It must also be the base for the underlying bufferevent.
underlyingA socket to use for this SSL
sslA SSL* object from openssl.
stateThe current state of the SSL connection
optionsOne or more bufferevent_options
Returns
A new bufferevent on success, or NULL on failure

◆ bufferevent_mbedtls_get_allow_dirty_shutdown()

EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_get_allow_dirty_shutdown ( struct bufferevent bev)

Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.

See also
BUFFEREVENT_SSL_DIRTY_SHUTDOWN
Deprecated:
This function is deprecated, use bufferevent_ssl_get_flags() instead.
See also
bufferevent_ssl_get_flags()

◆ bufferevent_mbedtls_set_allow_dirty_shutdown()

EVENT2_EXPORT_SYMBOL void bufferevent_mbedtls_set_allow_dirty_shutdown ( struct bufferevent bev,
int  allow_dirty_shutdown 
)

Set value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.

See also
BUFFEREVENT_SSL_DIRTY_SHUTDOWN
Deprecated:
This function is deprecated, use bufferevent_ssl_set_flags() instead.
See also
bufferevent_ssl_set_flags()

◆ bufferevent_mbedtls_socket_new()

EVENT2_EXPORT_SYMBOL struct bufferevent* bufferevent_mbedtls_socket_new ( struct event_base base,
evutil_socket_t  fd,
mbedtls_dyncontext *  ssl,
enum bufferevent_ssl_state  state,
int  options 
)

Create a new SSL bufferevent to send its data over an SSL * on a socket.

Parameters
baseAn event_base to use to detect reading and writing
fdA socket to use for this SSL
sslA SSL* object from mbedtls.
stateThe current state of the SSL connection
optionsOne or more bufferevent_options
Returns
A new bufferevent on success, or NULL on failure.

◆ bufferevent_openssl_filter_new()

EVENT2_EXPORT_SYMBOL struct bufferevent* bufferevent_openssl_filter_new ( struct event_base base,
struct bufferevent underlying,
struct ssl_st *  ssl,
enum bufferevent_ssl_state  state,
int  options 
)

Create a new SSL bufferevent to send its data over another bufferevent.

Parameters
baseAn event_base to use to detect reading and writing. It must also be the base for the underlying bufferevent.
underlyingA socket to use for this SSL
sslA SSL* object from openssl.
stateThe current state of the SSL connection
optionsOne or more bufferevent_options
Returns
A new bufferevent on success, or NULL on failure

◆ bufferevent_openssl_get_allow_dirty_shutdown()

EVENT2_EXPORT_SYMBOL int bufferevent_openssl_get_allow_dirty_shutdown ( struct bufferevent bev)

Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.

See also
BUFFEREVENT_SSL_DIRTY_SHUTDOWN
Deprecated:
This function is deprecated, use bufferevent_ssl_get_flags() instead.
See also
bufferevent_ssl_get_flags()

◆ bufferevent_openssl_set_allow_dirty_shutdown()

EVENT2_EXPORT_SYMBOL void bufferevent_openssl_set_allow_dirty_shutdown ( struct bufferevent bev,
int  allow_dirty_shutdown 
)

Set value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.

See also
BUFFEREVENT_SSL_DIRTY_SHUTDOWN
Deprecated:
This function is deprecated, use bufferevent_ssl_set_flags() instead.
See also
bufferevent_ssl_set_flags()

◆ bufferevent_openssl_socket_new()

EVENT2_EXPORT_SYMBOL struct bufferevent* bufferevent_openssl_socket_new ( struct event_base base,
evutil_socket_t  fd,
struct ssl_st *  ssl,
enum bufferevent_ssl_state  state,
int  options 
)

Create a new SSL bufferevent to send its data over an SSL * on a socket.

Parameters
baseAn event_base to use to detect reading and writing
fdA socket to use for this SSL
sslA SSL* object from openssl.
stateThe current state of the SSL connection
optionsOne or more bufferevent_options
Returns
A new bufferevent on success, or NULL on failure.