I need to create an HTTP server (not HTTPS with OpenSSL Cretification), with basic authentication (username & password).
I get examples to connect with HTTP server as a client with basic authentication...
sp_http_client_config_t config = {
.url = "http://user:passwd@httpbin.org/basic-auth/user/passwd",
.event_handler = _http_event_handler,
.auth_type = HTTP_AUTH_TYPE_BASIC,
As I investigated further with structure of "httpd_config_t" .........
/**
* Custom session opening callback.
*
* Called on a new session socket just after accept(), but before reading any data.
*
* This is an opportunity to set up e.g. SSL encryption using global_transport_ctx
* and the send/recv/pending session overrides.
*
* If a context needs to be maintained between these functions, store it in the session using
* httpd_sess_set_transport_ctx() and retrieve it later with httpd_sess_get_transport_ctx()
*
* Returning a value other than ESP_OK will immediately close the new socket.
*/
httpd_open_func_t open_fn;
/**
* @brief Function prototype for opening a session.
*
* Called immediately after the socket was opened to set up the send/recv functions and
* other parameters of the socket.
*
* @param[in] hd server instance
* @param[in] sockfd session socket file descriptor
* @return
* - ESP_OK : On success
* - Any value other than ESP_OK will signal the server to close the socket immediately
*/
typedef esp_err_t (*httpd_open_func_t)(httpd_handle_t hd, int sockfd);
I think "open_fn" can help, but don't know how.
Can anyone help me create an HTTP server with Username & Password as authentication method.
Creating HTTP Server with Basic Authentication
Who is online
Users browsing this forum: Kniroxe and 62 guests