GNU libmicrohttpd  0.9.29
connection_https.c File Reference

Methods for managing SSL/TLS connections. This file is only compiled if ENABLE_HTTPS is set. More...

#include "internal.h"
#include "connection.h"
#include "connection_https.h"
#include "memorypool.h"
#include "response.h"
#include "mhd_mono_clock.h"
#include <gnutls/gnutls.h>
Include dependency graph for connection_https.c:

Go to the source code of this file.

Functions

static int run_tls_handshake (struct MHD_Connection *connection)
 
static int MHD_tls_connection_handle_read (struct MHD_Connection *connection)
 
static int MHD_tls_connection_handle_write (struct MHD_Connection *connection)
 
static int MHD_tls_connection_handle_idle (struct MHD_Connection *connection)
 
void MHD_set_https_callbacks (struct MHD_Connection *connection)
 
int MHD_tls_connection_shutdown (struct MHD_Connection *connection)
 

Detailed Description

Methods for managing SSL/TLS connections. This file is only compiled if ENABLE_HTTPS is set.

Author
Sagie Amir
Christian Grothoff

Definition in file connection_https.c.

Function Documentation

◆ MHD_set_https_callbacks()

void MHD_set_https_callbacks ( struct MHD_Connection connection)

Set connection callback function to be used through out the processing of this secure connection.

Parameters
connectionwhich callbacks should be modified

Definition at line 176 of file connection_https.c.

References MHD_Connection::idle_handler, MHD_tls_connection_handle_idle(), MHD_tls_connection_handle_read(), MHD_tls_connection_handle_write(), MHD_Connection::read_handler, and MHD_Connection::write_handler.

Referenced by internal_add_connection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_tls_connection_handle_idle()

static int MHD_tls_connection_handle_idle ( struct MHD_Connection connection)
static

This function was created to handle per-connection processing that has to happen even if the socket cannot be read or written to. All implementations (multithreaded, external select, internal select) call this function.

Parameters
connectionbeing handled
Returns
MHD_YES if we should continue to process the connection (not dead yet), MHD_NO if it died

Definition at line 133 of file connection_https.c.

References _, MHD_Connection::connection_timeout, MHD_Connection::daemon, MHD_Connection::last_activity, MHD_connection_close_(), MHD_CONNECTION_CLOSED, MHD_connection_handle_idle(), MHD_monotonic_sec_counter(), MHD_REQUEST_TERMINATED_TIMEOUT_REACHED, MHD_TLS_CONNECTION_INIT, MHD_YES, MHD_Connection::state, and MHD_Connection::suspended.

Referenced by MHD_set_https_callbacks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_tls_connection_handle_read()

static int MHD_tls_connection_handle_read ( struct MHD_Connection connection)
static

This function handles a particular SSL/TLS connection when it has been determined that there is data to be read off a socket. Message processing is done by message type which is determined by peeking into the first message type byte of the stream.

Error message handling: all fatal level messages cause the connection to be terminated.

Application data is forwarded to the underlying daemon for processing.

Parameters
connectionthe source connection
Returns
always MHD_YES (we should continue to process the connection)

Definition at line 97 of file connection_https.c.

References MHD_connection_handle_read(), MHD_YES, and run_tls_handshake().

Referenced by MHD_set_https_callbacks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_tls_connection_handle_write()

static int MHD_tls_connection_handle_write ( struct MHD_Connection connection)
static

This function was created to handle writes to sockets when it has been determined that the socket can be written to. This function will forward all write requests to the underlying daemon unless the connection has been marked for closing.

Returns
always MHD_YES (we should continue to process the connection)

Definition at line 114 of file connection_https.c.

References MHD_connection_handle_write(), MHD_YES, and run_tls_handshake().

Referenced by MHD_set_https_callbacks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_tls_connection_shutdown()

int MHD_tls_connection_shutdown ( struct MHD_Connection connection)

Initiate shutdown of TLS layer of connection.

Parameters
connectionto use
Returns
MHD_YES if succeed, MHD_NO otherwise.

Definition at line 191 of file connection_https.c.

References MHD_NO, and MHD_YES.

Referenced by MHD_connection_mark_closed_().

Here is the caller graph for this function:

◆ run_tls_handshake()

static int run_tls_handshake ( struct MHD_Connection connection)
static

Give gnuTLS chance to work on the TLS handshake.

Parameters
connectionconnection to handshake on
Returns
MHD_YES on error or if the handshake is progressing MHD_NO if the handshake has completed successfully and we should start to read/write data

Definition at line 47 of file connection_https.c.

References _, MHD_Connection::daemon, MHD_connection_close_(), MHD_CONNECTION_INIT, MHD_NO, MHD_REQUEST_TERMINATED_WITH_ERROR, MHD_TLS_CONNECTION_INIT, MHD_update_last_activity_(), MHD_YES, and MHD_Connection::state.

Referenced by MHD_tls_connection_handle_read(), and MHD_tls_connection_handle_write().

Here is the call graph for this function:
Here is the caller graph for this function: