# &develguide;

## TLS_SERVER

### SSL data per connection

Each TLS connection, incoming or outgoing, creates an SSL * object, where configuration inherited from the SSL_CTX * and particular info on that socket are stored. This SSL * structure is kept in &osips; as long as the connection is alive, as part of the struct tcp_connection * object:

    ...
    struct tcp_connection *c;
    SSL *ssl;

    /*create somehow SSL object*/
    c->extra_data = (void *) ssl;
    ssl = (SSL *) c->extra_data;
    ...

### tls_print_errstack

void tls_print_errstack(void);

Dumps ssl error stack.

### tls_tcpconn_init

int tls_tcpconn_init( struct tcp_connection *c, int fd);

Called when new tcp connection is accepted

### tls_tcpconn_clean

void tls_tcpconn_clean( struct tcp_connection *c);

Shuts down the TLS connection.

### tls_blocking_write

size_t tls_blocking_write( struct tcp_connection *c, int fd, const char *buf, size_t len);

Writes a memory chunk in blocking mode (syncron).

### tls_read

size_t tls_read( struct tcp_connection *c);

Reads from a TLS connection. Return the number of bytes read.

### tls_fix_read_conn

void tls_tcpconn_clean( struct tcp_connection *c);

Shuts down the TLS connection.