0

我尝试将库 mbedTLS 与 LwIP 2.1.0 集成。我已将以下内容添加到我的 lwipopts.h 文件中

#ifndef LWIP_ALTCP
#define LWIP_ALTCP 1
#endif

#ifndef LWIP_ALTCP_TLS
#define LWIP_ALTCP_TLS 1
#endif

我已经像这样将库添加到我的项目中,并为编译器引用了它们:

在此处输入图像描述

我还在 mbedtls/include/config.h 文件中进行了更改,以便不使用 windows 或 linux。

我得到了一个“对“_gettimeofday”的未定义引用,我将它缩小到唯一定义它的地方是在我的 arm-gnu 工具链中:

#ifdef _COMPILING_NEWLIB
int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
#endif

可能是什么情况?当我关闭 LWIP_ALTCP_TLS 时,一切都会编译文件,但随后无法使用 TLS。我需要打开/关闭更多标志吗?

4

1 回答 1

1

RTFM:该_gettimeofday()函数是用户在使用 newlib 中的日期和时间函数时必须实现的系统调用。

最小实现相当简单:

int _gettimeofday (struct timeval *tp, void *tzp){
  tp->tv_sec = unixTimeInSecs;
  tp->tv_usec = 0; 
  return 0;
}

TLS 库需要当前时间进行证书检查:SSL 证书仅在特定日期范围内有效。

于 2019-12-05T12:54:17.473 回答