File tree 5 files changed +36
-0
lines changed 5 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ CONFIG_LWIP_PPP_CHAP_SUPPORT=y
59
59
# SSL
60
60
# Use 4kiB output buffer instead of default 16kiB
61
61
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
62
+ CONFIG_MBEDTLS_HAVE_TIME_DATE=y
63
+ CONFIG_MBEDTLS_PLATFORM_TIME_ALT=y
64
+ CONFIG_MBEDTLS_HAVE_TIME=y
62
65
63
66
# Disable ALPN support as it's not implemented in MicroPython
64
67
CONFIG_MBEDTLS_SSL_ALPN=n
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ list(APPEND MICROPY_SOURCE_PORT
63
63
mphalport.c
64
64
fatfs_port.c
65
65
help.c
66
+ mbedtls/mbedtls_port.c
66
67
machine_bitstream.c
67
68
machine_timer.c
68
69
machine_pin.c
Original file line number Diff line number Diff line change 64
64
#include "modespnow.h"
65
65
#endif
66
66
67
+ // mbedtls time cert validation
68
+ #include "mbedtls/platform_time.h"
69
+ #include "mbedtls/mbedtls_config.h"
70
+
67
71
// MicroPython runs as a task under FreeRTOS
68
72
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
69
73
@@ -97,6 +101,8 @@ void mp_task(void *pvParameter) {
97
101
uart_stdout_init ();
98
102
#endif
99
103
machine_init ();
104
+ // mbedtls time cert validation
105
+ mbedtls_platform_set_time (platform_mbedtls_time );
100
106
101
107
esp_err_t err = esp_event_loop_create_default ();
102
108
if (err != ESP_OK ) {
Original file line number Diff line number Diff line change
1
+ // Time mbedtls_platform
2
+ #include <time.h>
3
+ #include <sys/time.h>
4
+
5
+ #define MBEDTLS_HAVE_ASM
6
+
7
+ time_t platform_mbedtls_time (time_t * timer );
Original file line number Diff line number Diff line change
1
+ #include <py/mpconfig.h>
2
+
3
+ #ifdef MICROPY_SSL_MBEDTLS
4
+
5
+ #include <time.h>
6
+ #include <sys/time.h>
7
+ #include "shared/timeutils/timeutils.h"
8
+ #include "mbedtls/platform_time.h"
9
+
10
+ time_t platform_mbedtls_time (time_t * timer ) {
11
+ // mbedtls_time requires time in seconds from EPOCH 1970
12
+
13
+ struct timeval tv ;
14
+ gettimeofday (& tv , NULL );
15
+
16
+ return tv .tv_sec + TIMEUTILS_SECONDS_1970_TO_2000 ;
17
+ }
18
+
19
+ #endif
You can’t perform that action at this time.
0 commit comments