diff --git a/src/microhttpd/connection_https_openssl.c b/src/microhttpd/connection_https_openssl.c index 0da44860..2e82f7fd 100644 --- a/src/microhttpd/connection_https_openssl.c +++ b/src/microhttpd/connection_https_openssl.c @@ -65,6 +65,33 @@ MHD_TLS_openssl_init (void *ctx) FILE *err_file; +/** + * Callback for receiving data from the socket. + * + * @param connection the MHD_Connection structure + * @param other where to write received data to + * @param i maximum size of other (in bytes) + * @return positive value for number of bytes actually received or + * negative value for error number MHD_ERR_xxx_ + */ +static ssize_t +recv_tls_adapter_openssl_ (struct MHD_Connection *connection, + void *other, + size_t i) +{ + ssize_t res; + + if (i > SSIZE_MAX) + i = SSIZE_MAX; + + res = SSL_read (connection->tls.openssl.ssl, + other, + i); + // TODO error handling + return res +} + + /** * Initialize the OpenSSL library */ @@ -172,6 +199,19 @@ MHD_run_tls_handshake_openssl_ (struct MHD_Connection *connection) } +/** + * Set connection callback function to be used through out + * the processing of this secure connection. + * + * @param connection which callbacks should be modified + */ +void +MHD_set_https_callbacks_openssl_ (struct MHD_Connection *connection) +{ + connection->recv_cls = &recv_tls_adapter_openssl_; +} + + /** * Close the connection with the server * diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index b7a265d2..6ae801ba 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h @@ -1199,6 +1199,11 @@ union TLS_ConnectionState #if 1 || TLS_SUPPORT_OPENSSL struct { + /** + * State required for HTTPS/SSL/TLS support. + */ + SSL *ssl; + /** * State of connection's TLS layer * To modify