@@ -5,26 +5,113 @@ if(CONFIG_ESP_TLS_USING_MBEDTLS)
5
5
endif ()
6
6
7
7
if (CONFIG_ESP_TLS_USING_WOLFSSL)
8
+ message (STATUS "esp-tls configured for wolfssl" )
8
9
list (APPEND srcs
9
10
"esp_tls_wolfssl.c" )
11
+ set (wolfssl_esp_tls_lib "wolfssl" )
12
+ else ()
13
+ unset (wolfssl_esp_tls_lib)
10
14
endif ()
11
15
12
16
set (priv_req http_parser esp_timer)
13
17
if (NOT ${IDF_TARGET} STREQUAL "linux" )
14
18
list (APPEND priv_req lwip)
15
19
endif ()
16
20
21
+ message (STATUS "idf_component_register wolfssl_esp_tls_lib: ${wolfssl_esp_tls_lib} " )
22
+
17
23
idf_component_register(SRCS "${srcs} "
18
24
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} esp-tls-crypto
19
25
PRIV_INCLUDE_DIRS "private_include"
20
26
# mbedtls is public requirements because esp_tls.h
21
27
# includes mbedtls header files.
22
- REQUIRES mbedtls
28
+ REQUIRES mbedtls ${wolfssl_esp_tls_lib}
23
29
PRIV_REQUIRES ${priv_req} )
24
30
31
+ # When using wolfSSL for the ESP-TLS (see menuconfig),
32
+ # There are two options:
33
+ # 1) A specified source directory, typically a wolfssl git clone
34
+ # 2) The esp-wolfssl
35
+ # TODO this is duplicate code. See components/wap_supplicant
36
+ message (STATUS "esp-tls config begin" )
25
37
if (CONFIG_ESP_TLS_USING_WOLFSSL)
26
- idf_component_get_property(wolfssl esp-wolfssl COMPONENT_LIB)
27
- target_link_libraries (${COMPONENT_LIB} PUBLIC ${wolfssl} )
38
+ message (STATUS "found CONFIG_ESP_TLS_USING_WOLFSSL" )
39
+ # See https://github.com/wolfSSL/wolfssl/
40
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESPIDF" )
41
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS" )
42
+
43
+ # The published wolfSSL 5.7.0 user_settings.h does not include some features that
44
+ # might be enabled in Kconfig, so enable them here:
45
+ # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_ALPN")
46
+ # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_SNI")
47
+ # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOPENSSL_EXTRA_X509_SMALL")
48
+ # this only works for VisualGDB, not idf.py from command-line
49
+
50
+ message (STATUS "CMAKE_HOME_DIRECTORY = ${CMAKE_HOME_DIRECTORY} " )
51
+ message (STATUS "CMAKE_PARENT_LIST_FILE = ${CMAKE_PARENT_LIST_FILE} " )
52
+ message (STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR} " )
53
+ message (STATUS "COMPONENT_DIR = ${CMAKE_HOME_DIRECTORY} " )
54
+ message (STATUS "COMPONENT_LIB = ${COMPONENT_LIB} " )
55
+ message (STATUS "FOUND_WOLFSSL = ${FOUND_WOLFSSL} " )
56
+ message (STATUS "PROJECT_DIR = ${PROJECT_DIR} " )
57
+ message (STATUS "WOLFSSL_PROJECT_DIR = ${WOLFSSL_PROJECT_DIR} " )
58
+ message (STATUS "CMAKE_HOME_DIRECTORY = ${CMAKE_HOME_DIRECTORY} " )
59
+ message (STATUS "WOLFSSL_ROOT = ${WOLFSSL_ROOT} " )
60
+
61
+ if (CONFIG_ESP_TLS_USING_WOLFSSL_SPECIFIED)
62
+ get_filename_component (CUSTOM_SETTING_WOLFSSL_ROOT_PATH "${CUSTOM_SETTING_WOLFSSL_ROOT} " ABSOLUTE )
63
+ if (EXISTS "${CUSTOM_SETTING_WOLFSSL_ROOT_PATH} /wolfcrypt/src" )
64
+ message (STATUS "ESP-TLS using wolfSSL in: ${CUSTOM_SETTING_WOLFSSL_ROOT_PATH} " )
65
+ else ()
66
+ message (STATUS "ESP-TLS specified directory does not contain wolfSSL: ${CUSTOM_SETTING_WOLFSSL_ROOT_PATH} " )
67
+ endif ()
68
+ idf_component_get_property(wolfssl wolfssl COMPONENT_LIB)
69
+ target_link_libraries (${COMPONENT_LIB} PUBLIC ${wolfssl} )
70
+ else ()
71
+ # Is wolfSSL installed in the local project as a Managed Component?
72
+ set (WOLFSSL_COMPONENT_SEARCH "${PROJECT_DIR} /managed_components/wolfssl__wolfssl" )
73
+ message (STATUS "Searching for wolfSSL in ${WOLFSSL_COMPONENT_SEARCH} " )
74
+ if (EXISTS "${WOLFSSL_COMPONENT_SEARCH} " )
75
+ message (STATUS "Configuring ESP-IDF to use wolfssl in Managed Component: ${WOLFSSL_COMPONENT_SEARCH} " )
76
+ idf_component_get_property(wolfssl wolfssl__wolfssl COMPONENT_LIB)
77
+ else ()
78
+ # Is wolfSSL installed in the local project as a Managed Component
79
+ # converted to regular project component?
80
+ set (WOLFSSL_COMPONENT_SEARCH "${PROJECT_DIR} /components/wolfssl__wolfssl" )
81
+ message (STATUS "Searching for wolfSSL in ${WOLFSSL_COMPONENT_SEARCH} " )
82
+ if (EXISTS "${WOLFSSL_COMPONENT_SEARCH} " )
83
+ message (STATUS
84
+ "Configuring ESP-IDF to use wolfssl in Converted Managed Component: ${WOLFSSL_COMPONENT_SEARCH} " )
85
+ idf_component_get_property(wolfssl wolfssl__wolfssl COMPONENT_LIB)
86
+ else ()
87
+ # Is wolfSSL installed in the local project as a non-maged, regular component?
88
+ set (WOLFSSL_COMPONENT_SEARCH "${PROJECT_DIR} /components/wolfssl" )
89
+ message (STATUS "Searching for wolfSSL in ${WOLFSSL_COMPONENT_SEARCH} " )
90
+ if (EXISTS "${WOLFSSL_COMPONENT_SEARCH} " )
91
+ message (STATUS "Configuring ESP-IDF to use wolfssl in Component: ${WOLFSSL_COMPONENT_SEARCH} " )
92
+ idf_component_get_property(wolfssl wolfssl COMPONENT_LIB)
93
+ else ()
94
+ set (WOLFSSL_COMPONENT_SEARCH "${THIS_IDF_PATH} /components/esp-wolfssl" )
95
+ message (STATUS "Searching for wolfSSL in ${WOLFSSL_COMPONENT_SEARCH} " )
96
+ if (EXISTS "${WOLFSSL_COMPONENT_SEARCH} " )
97
+ message (STATUS "Configuring ESP-IDF to use wolfssl from: ${WOLFSSL_COMPONENT_SEARCH} " )
98
+ message (STATUS "Warning: Using legacy esp-wolfssl. Consider using a Managed Component" )
99
+ # See https://github.com/espressif/esp-idf
100
+ message (STATUS "Configuring ESP-TLS to use esp-wolfssl" )
101
+ idf_component_get_property(wolfssl esp-wolfssl COMPONENT_LIB)
102
+ else ()
103
+ message (STATUS "Consider installing wolfSSL from "
104
+ "https://components.espressif.com/components/wolfssl/wolfssl" )
105
+ message (FATAL_ERROR "Component ${component} not found" )
106
+ endif () # esp-wolfssl
107
+ endif () # project wolfssl
108
+ endif () # project converted wolfssl__wolfssl
109
+ endif () # project managed component wolfssl__wolfssl
110
+ # idf_component_get_property(wolfssl wolfssl__wolfssl COMPONENT_LIB)
111
+ target_link_libraries (${COMPONENT_LIB} PUBLIC ${wolfssl} )
112
+ endif ()
113
+ else ()
114
+ message (STATUS "ESP-TLS is not configured to use wolfSSL." )
28
115
endif ()
29
116
30
117
if (NOT ${IDF_TARGET} STREQUAL "linux" )
0 commit comments