ESP32采用SSL连接阿里云注服务器失败

hweing
Posts: 1
Joined: Tue Sep 24, 2019 1:18 pm

ESP32采用SSL连接阿里云注服务器失败

Postby hweing » Tue Sep 24, 2019 1:21 pm

串口输出日志:
DEBUG,t:20.85,m:211.06,[HTTPS] connection to aliyun server ...
[D][HTTPClient.cpp:276] beginInternal(): host: iot-auth.cn-shanghai.aliyuncs.com port: 443 url: /auth/register/device
PS] POST...
DEBUG,t:20.86,m:210.86,ali device register:productKey=a1AyzHf9sXq&deviceName=7D12CFA4&random=20864&sign=208ADB5862D0FD3F5591BFB88A03FC6B6A08F6EBDC4423897691AA884D93B32D&signMethod=hmacsha256
[D][HTTPClient.cpp:1025] connect(): connected to iot-auth.cn-shanghai.aliyuncs.com:443
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[W][HTTPClient.cpp:1318] returnError(): error(-2): send header failed
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[D][HTTPClient.cpp:1320] returnError(): tcp stop
[HTTPS] POST... failed, error: send header failed
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928

代码片段:
WiFiClientSecure* _client = new WiFiClientSecure;
if (!_client)return false;
_client->setCACert(root_ca);
AliMqttAuth auth = Config.ali_mqtt;
HTTPClient _https;
sprintf(host, "https://iot-auth.%s.aliyuncs.com/auth/register/device", auth.region_id);
INFO.print_debug("[HTTPS] connection to aliyun server ...\r\n");
if (_https.begin(*_client, host)) { // HTTPS
INFO.print("[HTTPS] POST...\r\n");
prepare_data();
// start connection and send HTTP header
size_t len = strlen(post_data);
_https.addHeader("Content-Type", "application/x-www-form-urlencoded");
_https.addHeader("Content-Length", String(len));
int httpCode = _https.POST((uint8_t*)post_data, strlen(post_data));

Who is online

Users browsing this forum: No registered users and 2 guests