c++ - Arduino ESP8266HTTPClient : Handshake failure (SSL error 40)

标签 c++ ssl arduino esp8266 arduino-esp8266

我遇到了 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();

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

状态:发送 Client Hello (1) 警报:握手失败 错误:SSL 错误 40 警报:意外消息 错误:SSL 错误 40 警报:关闭通知 [HTTP-Client] 无法连接到 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只有两个受支持的密码套件:

  • TLS_RSA_WITH_AES_128_CBC_SHA 和
  • TLS_RSA_WITH_AES_256_CBC_SHA

主机支持以下密码套件:

  • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

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

最佳答案

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

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

关于c++ - Arduino ESP8266HTTPClient : Handshake failure (SSL error 40),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49878604/

相关文章:

c++ - Arduino 脚本问题

java - 带有处理功能的 Skype API 或 Arduino

c++ - 并行但无锁地将数据刷新到磁盘?

c++ - boost::bimap 中的移位值

apache - SSL:我可以在同一台服务器上对 Web 和邮件服务使用相同的 SSL 证书吗?

ssl - 从普遍信任的证书创建我自己的中间证书颁发机构

c++ - VC11 Winsock 应用程序不会关闭

c++ - 分配在 "stack"上的 vector 可以在函数之间传递吗?

java - HttpClient https Post 请求失败

arduino - 如何在Arduino中匹配字符串中的文本