Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sockfd field to esp_https_server_user_cb_arg_t (IDFGH-10937) #12132

Closed
dannybackx opened this issue Aug 23, 2023 · 2 comments
Closed

Add sockfd field to esp_https_server_user_cb_arg_t (IDFGH-10937) #12132

dannybackx opened this issue Aug 23, 2023 · 2 comments
Assignees
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@dannybackx
Copy link

dannybackx commented Aug 23, 2023

Is your feature request related to a problem?

I have trouble putting the esp_https_server to use with authenticated clients.
Previous remarks I made resulted in adding functionality, however one of the fields I suggested was dropped. See (IDFGH-6652) #8288.

The user_cb is good to pass me the TLS info, but if I want to match that later on (in handlers of the HTTPS server), I don't seem to know which session I'm in.

The socket appears like a good handle for that. It was in my sample code but got dropped, I am asking again to include it.

Describe the solution you'd like.

hp: {1564} diff -c include/esp_https_server.h.orig include/esp_https_server.h ; diff -c src/https_server.c.orig src/https_server.c
*** include/esp_https_server.h.orig     2023-08-23 04:36:08.000000000 +0200
--- include/esp_https_server.h  2023-08-23 17:34:15.950839687 +0200
***************
*** 36,41 ****
--- 36,42 ----
   */
  typedef struct esp_https_server_user_cb_arg {
      httpd_ssl_user_cb_state_t user_cb_state; /*!< State of user callback */
+     int sockfd;                               /*!< Socket of the https connection */
      esp_tls_t *tls;                    /*!< ESP-TLS connection handle */
  } esp_https_server_user_cb_arg_t;
  
*** src/https_server.c.orig     2023-08-23 04:36:08.000000000 +0200
--- src/https_server.c  2023-08-23 17:35:10.566596608 +0200
***************
*** 40,45 ****
--- 40,46 ----
          esp_https_server_user_cb_arg_t user_cb_data = {0};
          user_cb_data.user_cb_state = HTTPD_SSL_USER_CB_SESS_CLOSE;
          user_cb_data.tls = tls;
+       user_cb_data.sockfd = -1;
          (global_ctx->user_cb)((void *)&user_cb_data);
      }
  
***************
*** 158,163 ****
--- 159,165 ----
          esp_https_server_user_cb_arg_t user_cb_data = {0};
          user_cb_data.user_cb_state = HTTPD_SSL_USER_CB_SESS_CREATE;
          user_cb_data.tls = tls;
+       user_cb_data.sockfd = sockfd;
          (global_ctx->user_cb)((void *)&user_cb_data);
      }
  

Describe alternatives you've considered.

See https://sourceforge.net/p/esp32s3-4827s043/code/HEAD/tree/trunk/https/main/WebServer.cpp

specifically the WebServer::isPeerSecure() to see where I need additional info.

Please take commit #81, in a later version I'm speculating that you'll help me by adding this field ;-)

Additional context.

No response

@dannybackx dannybackx added the Type: Feature Request Feature request for IDF label Aug 23, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 23, 2023
@github-actions github-actions bot changed the title Add sockfd field to esp_https_server_user_cb_arg_t Add sockfd field to esp_https_server_user_cb_arg_t (IDFGH-10937) Aug 23, 2023
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Aug 28, 2023
@laukik-hase
Copy link
Collaborator

laukik-hase commented Sep 22, 2023

Hello, @dannybackx!

Sorry for the late response. I think we can add the sockfd field to the callback arguments structure.

Could you explain a bit more on why the approach taken in the https_server/simple example (see here) is not feasible for your implementation?

@dannybackx
Copy link
Author

Hmm, it is. My apologies, I overlooked this.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Won't Do This will not be worked on and removed Status: In Progress Work is in progress labels Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

3 participants