protocols.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. Protocols
  2. =========
  3. .. _migration_guide_mbedtls:
  4. Mbed TLS
  5. --------
  6. For ESP-IDF v5.0, `Mbed TLS <https://github.com/Mbed-TLS/mbedtls>`_ has been updated from v2.x to v3.1.0.
  7. The official guide for Mbed TLS to migrate from version 2.x to version 3.0 or greater can be found `here <https://github.com/espressif/mbedtls/blob/9bb5effc3298265f829878825d9bd38478e67514/docs/3.0-migration-guide.md>`__.
  8. Breaking Changes (Summary)
  9. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. Most structure fields are now private
  11. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  12. - Direct access to fields of structures (``struct`` types) declared in public headers is no longer supported.
  13. - Appropriate accessor functions (getter/setter) must be used for the same. A temporary workaround would be to use ``MBEDTLS_PRIVATE`` macro (**not recommended**).
  14. - For more details, refer to the official guide `here <https://github.com/espressif/mbedtls/blob/9bb5effc3298265f829878825d9bd38478e67514/docs/3.0-migration-guide.md#most-structure-fields-are-now-private>`__.
  15. SSL
  16. ^^^
  17. - Removed support for TLS 1.0, 1.1 and DTLS 1.0
  18. - Removed support for SSL 3.0
  19. Deprecated functions were removed from cryptography modules
  20. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  21. - The functions ``mbedtls_*_ret()`` (related to MD, SHA, RIPEMD, RNG, HMAC modules) was renamed to replace the corresponding functions without ``_ret`` appended and updated return value.
  22. - For more details, refer to the official guide `here <https://github.com/espressif/mbedtls/blob/9bb5effc3298265f829878825d9bd38478e67514/docs/3.0-migration-guide.md#deprecated-functions-were-removed-from-hashing-modules>`__.
  23. Deprecated Config Options
  24. ^^^^^^^^^^^^^^^^^^^^^^^^^
  25. Following are some of the important config options deprecated by this update. The configs related to and/or dependent on these have also been deprecated.
  26. - ``MBEDTLS_SSL_PROTO_SSL3`` : Support for SSL 3.0
  27. - ``MBEDTLS_SSL_PROTO_TLS1`` : Support for TLS 1.0
  28. - ``MBEDTLS_SSL_PROTO_TLS1_1``: Support for TLS 1.1
  29. - ``MBEDTLS_SSL_PROTO_DTLS`` : Support for DTLS 1.1 (Only DTLS 1.2 is supported now)
  30. - ``MBEDTLS_DES_C`` : Support for 3DES ciphersuites
  31. - ``MBEDTLS_RC4_MODE`` : Support for RC4-based ciphersuites
  32. .. note:: This list includes only major options configurable through ``idf.py menuconfig``. For more details on deprecated options, refer to the official migration guide.
  33. Miscellaneous
  34. -------------
  35. Disabled Diffie-Hellman Key Exchange modes
  36. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. The Diffie-Hellman Key Exchange modes have now been disabled by default due to security risks (see warning text `here <https://github.com/espressif/mbedtls/blob/9bb5effc3298265f829878825d9bd38478e67514/include/mbedtls/dhm.h#L20>`__). Related configs are given below:
  38. - ``MBEDTLS_DHM_C`` : Support for the Diffie-Hellman-Merkle module
  39. - ``MBEDTLS_KEY_EXCHANGE_DHE_PSK`` : Support for Diffie-Hellman PSK (pre-shared-key) TLS authentication modes
  40. - ``MBEDTLS_KEY_EXCHANGE_DHE_RSA`` : Support for cipher suites with the prefix ``TLS-DHE-RSA-WITH-``
  41. .. note:: During the initial step of the handshake (i.e. ``client_hello``), the server selects a cipher from the list that the client publishes. As the DHE_PSK/DHE_RSA ciphers have now been disabled by the above change, the server would fall back to an alternative cipher; if in a rare case, it does not support any other cipher, the handshake would fail. To retrieve the list of ciphers supported by the server, one must attempt to connect with the server with a specific cipher from the client-side. Few utilities can help do this, e.g. ``sslscan``.
  42. Remove ``certs`` module from X509 library
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. - The ``mbedtls/certs.h`` header is no longer available in mbedtls 3.1, most applications can safely remove it from the list of includes.
  45. Breaking change for ``esp_crt_bundle_set`` API
  46. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. - The :cpp:func:`esp_crt_bundle_set()` API now requires one additional argument named ``bundle_size``. The return type of the API has also been changed to :cpp:type:`esp_err_t` from ``void``.
  48. Breaking change for ``esp_ds_rsa_sign`` API
  49. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. - The :cpp:func:`esp_ds_rsa_sign()` API now requires one less argument. The argument ``mode`` is no longer required.
  51. HTTPS Server
  52. ------------
  53. Breaking Changes (Summary)
  54. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. Names of variables holding different certs in :cpp:type:`httpd_ssl_config_t` structure have been updated.
  56. .. list::
  57. * :cpp:member:`httpd_ssl_config::servercert` variable inherits role of `cacert_pem` variable.
  58. * :cpp:member:`httpd_ssl_config::servercert_len` variable inherits role of `cacert_len` variable
  59. * :cpp:member:`httpd_ssl_config::cacert_pem` variable inherits role of `client_verify_cert_pem` variable
  60. * :cpp:member:`httpd_ssl_config::cacert_len` variable inherits role of `client_verify_cert_len` variable
  61. The return type of the :cpp:func:`httpd_ssl_stop` API has been changed to :cpp:type:`esp_err_t` from ``void``.
  62. ESP HTTPS OTA
  63. --------------
  64. Breaking Changes (Summary)
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. - The function :cpp:func:`esp_https_ota` now requires pointer to :cpp:type:`esp_https_ota_config_t` as argument instead of pointer to :cpp:type:`esp_http_client_config_t`.
  67. ESP-TLS
  68. --------------
  69. Breaking Changes (Summary)
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. ``esp_tls_t`` structure is now private
  72. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  73. The :cpp:type:`esp_tls_t` has now been made completely private. You cannot access its internal structures directly. Any necessary data that needs to be obtained from the esp-tls handle can be done through respective getter/setter functions. If there is a requirement of a specific getter/setter function please raise an issue on ESP-IDF.
  74. The list of newly added getter/setter function is as as follows:
  75. .. list::
  76. * :cpp:func:`esp_tls_get_ssl_context` - Obtain the ssl context of the underlying ssl stack from the esp-tls handle.
  77. Function deprecations and recommended alternatives
  78. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  79. Following table summarizes the deprecated functions removed and their alternatives to be used from ESP-IDF v5.0 onwards.
  80. +-----------------------------------+----------------------------------------+
  81. | Function | Alternative |
  82. +===================================+========================================+
  83. | :cpp:func:`esp_tls_conn_new` | :cpp:func:`esp_tls_conn_new_sync` |
  84. +-----------------------------------+----------------------------------------+
  85. | :cpp:func:`esp_tls_conn_delete` | :cpp:func:`esp_tls_conn_destroy` |
  86. +-----------------------------------+----------------------------------------+
  87. - The function :cpp:func:`esp_tls_conn_http_new` has now been termed as deprecated. Please use the alternative function :cpp:func:`esp_tls_conn_http_new_sync` (or its asynchronous :cpp:func:`esp_tls_conn_http_new_async`). Note that the alternatives need an additional parameter :cpp:type:`esp_tls_t` which has to be initialized using the :cpp:func:`esp_tls_init` function.
  88. HTTP Server
  89. -----------
  90. Breaking Changes (Summary)
  91. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  92. - ``http_server.h`` header is no longer available in ``esp_http_server``. Please use ``esp_http_server.h`` instead.
  93. ESP HTTP Client
  94. ---------------
  95. Breaking Changes (Summary)
  96. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. - The functions :cpp:func:`esp_http_client_read` and :cpp:func:`esp_http_client_fetch_headers` now return an additional return value ``-ESP_ERR_HTTP_EAGAIN`` for timeout errors - call timed-out before any data was ready.
  98. TCP Transport
  99. -------------
  100. Breaking Changes (Summary)
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. - The function :cpp:func:`esp_transport_read` now returns ``0`` for a connection timeout and ``< 0`` for other errors. Please refer :cpp:enum:`esp_tcp_transport_err_t` for all possible return values.
  103. MQTT Client
  104. -----------
  105. Breaking Changes (Summary)
  106. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  107. - :cpp:type:`esp_mqtt_client_config_t` have all fields grouped in sub structs.
  108. Most common configurations are listed below:
  109. - Broker address now is set in :cpp:member:`esp_mqtt_client_config_t::broker::address::uri`
  110. - Security related to broker verification in :cpp:member:`esp_mqtt_client_config_t::broker::verification`
  111. - Client username is set in :cpp:member:`esp_mqtt_client_config_t::credentials::username`
  112. ESP-Modbus
  113. ----------
  114. Breaking Changes (Summary)
  115. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  116. The ESP-IDF component ``freemodbus`` has been removed from ESP-IDF and will be supported as a separate component. Additional information for the ``ESP-Modbus`` component can be found in the separate repository:
  117. * `ESP-Modbus component on GitHub <https://www.github.com/espressif/esp-modbus>`__
  118. The ``main`` component folder of the new application shall include the component manager manifest file ``idf_component.yml`` as in example below:
  119. .. highlight:: none
  120. ::
  121. dependencies:
  122. espressif/esp-modbus:
  123. version: "^1.0"
  124. The ``esp-modbus`` component can be found in `component manager registry <https://components.espressif.com/component/espressif/esp-modbus>`__. Refer to `component manager documentation <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html>`__ for more information on how to set up the component manager.
  125. Applications targeting v4.x releases of ESP-IDF which use the new ``esp-modbus`` component should exclude the legacy ``freemodbus`` component from the build. This can be achieved using the below statement in project ``CMakeLists.txt``:
  126. .. highlight:: none
  127. ::
  128. set(EXCLUDE_COMPONENTS freemodbus)