esp_https_server.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. HTTPS server
  2. ============
  3. Overview
  4. --------
  5. This component is built on top of `esp_http_server`. The HTTPS server takes advantage of hooks and function overrides in the regular HTTP server to provide encryption using OpenSSL.
  6. All documentation for `esp_http_server` applies also to a server you create this way.
  7. Used APIs
  8. ---------
  9. The following API of `esp_http_server` should not be used with `esp_https_server`, as they are used internally to handle secure sessions and to maintain internal state:
  10. * "send", "receive" and "pending" function overrides - secure socket handling
  11. * :cpp:func:`httpd_sess_set_send_override`
  12. * :cpp:func:`httpd_sess_set_recv_override`
  13. * :cpp:func:`httpd_sess_set_pending_override`
  14. * "transport context" - both global and session
  15. * :cpp:func:`httpd_sess_get_transport_ctx` - returns SSL used for the session
  16. * :cpp:func:`httpd_sess_set_transport_ctx`
  17. * :cpp:func:`httpd_get_global_transport_ctx` - returns the shared SSL context
  18. * :c:member:`httpd_config_t.global_transport_ctx`
  19. * :c:member:`httpd_config_t.global_transport_ctx_free_fn`
  20. * :c:member:`httpd_config_t.open_fn` - used to set up secure sockets
  21. Everything else can be used without limitations.
  22. Usage
  23. -----
  24. Please see the example :example:`protocols/https_server` to learn how to set up a secure server.
  25. Basically all you need is to generate a certificate, embed it in the firmware, and provide its pointers and lengths to the start function via the init struct.
  26. The server can be started with or without SSL by changing a flag in the init struct - :c:member:`httpd_ssl_config.transport_mode`. This could be used e.g. for testing or in trusted environments where you prefer speed over security.
  27. Performance
  28. -----------
  29. The initial session setup can take about two seconds, or more with slower clock speeds or more verbose logging. Subsequent requests through the open secure socket are much faster (down to under
  30. 100 ms).
  31. API Reference
  32. -------------
  33. .. include-build-file:: inc/esp_https_server.inc