Arduino ESP8266HTTPClient:握手失败(SSL错误40)

Arduino ESP8266HTTPClient: Handshake failure (SSL error 40)

我遇到了 ESP8266HTTPClient 和 SSL 的问题。

#include <ESP8266HTTPClient.h>

const char* url= "https://someUrl.com";
const char* fingerPrint= "SO ME SH A1 FI NG ER PR IN T";

HTTPClient http;
http.begin(url, fingerPrint);
http.GET();

执行此操作时,我在调试日志中收到以下内容:

State: sending Client Hello (1) Alert: handshake failure Error: SSL error 40 Alert: unexpected message Error: SSL error 40 Alert: close notify [HTTP-Client] failed connect to someUrl.com:443

我尝试检查 grc 上的指纹并得到以下响应:

The SSL/TLS security certificate obtained from the remote server was invalid. The trouble was severe enough that we were unable to obtain the certificate's common name and/or fingerprint. There is a server answering on the HTTPS port 443 of the IP address associated with the domain name you supplied (shown above). But the server may be answering HTTPS as if it was HTTP and returning a web page rather than a proper SSL/TLS setup handshake. (We have encountered this behavior.)

这让我相信主机上的 SSL 配置有问题。 但是用我的浏览器(试过 IE、Edge 和 FireFox)访问 url 时证书没有问题。

根据 this comment to an issue on github 只有两个受支持的密码套件:

主机支持以下密码套件:

有没有机会在 ESP8266 上向该主机执行 HTTPS 请求?也许是另一个 HttpClient 库?

不幸的是,Arduino ESP8266 不适用,因为无论您使用什么 HTTP 客户端库,它都使用 axTLS。他们根本不支持它。

然而,不久前 Espressif 的 SDK 切换到了 mbedTLS,并且 mbedTLS Supported Cipher Suites 表明它包括对这些密码的支持。但是,使用 Arduino SDK 编写的代码在很大程度上与 Espressif SDK 不兼容。

根据 https://github.com/esp8266/Arduino/issues/2771,Arduino ESP8266 库现在正在切换到 BearSSL,据说它支持更多密码。不幸的是,我的知识不足(现在已经尝试了 2 天)来实施修复,因为我遇到了同样的问题(需要登录以捕获 SSL 上的门户以进行 wifi 访问),但希望我会很快找到答案。