• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

Нужна помощь Не работает httpS на ESP32 под ArduinoIDE

kotyara12

New member
Доброго времени, уважаемые!

Пытаюсь отправить GET запрос к httpS - серверу из скетча на ArduinoIDE. Но не работает, ни в какую.
Вначале думал, что проблема в сертификатах или сервере, но оказалось, что нет. Попробовал залить demo проект BasicHttpsClient.ino - та же проблема.
При попытке подключения в режиме verbose выдает следующее:
Код:
[D][WiFiMulti.cpp:178] run(): [WIFI] Channel: 12
Waiting for NTP time sync: .
Current time: Sun Sep 22 19:02:57 2019
[HTTPS] begin...
[V][HTTPClient.cpp:235] beginInternal(): url: https://jigsaw.w3.org/HTTP/connection.html
[D][HTTPClient.cpp:276] beginInternal(): host: jigsaw.w3.org port: 443 url: /HTTP/connection.html
[D][HTTPClient.cpp:1025] connect():  connected to jigsaw.w3.org: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
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:276] send_ssl_data(): Writing HTTP request...
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[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
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
[V][ssl_client.cpp:245] stop_ssl_socket(): Cleaning SSL connection.
[D][HTTPClient.cpp:1320] returnError(): tcp stop
Что самое интересное, что на ESP8266 демо скрипт HttpsClient тоже не может подключиться.
В чем может быть причина?
 

kotyara12

New member
[E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
И что это значит???? Где там плохие параметры???

PS: Сорри, не указал код, но он "стандартный". Ошибка вываливается в "if (https.begin(*client, "Connection Header"))":

Код:
void loop() {
  WiFiClientSecure *client = new WiFiClientSecure;
  if(client) {
    client -> setCACert(rootCACertificate);

    {
      // Add a scoping block for HTTPClient https to make sure it is destroyed before WiFiClientSecure *client is
      HTTPClient https;
 
      Serial.print("[HTTPS] begin...\n");
      if (https.begin(*client, "https://jigsaw.w3.org/HTTP/connection.html")) {  // HTTPS
        Serial.print("[HTTPS] GET...\n");
        // start connection and send HTTP header
        int httpCode = https.GET();
 
        // httpCode will be negative on error
        if (httpCode > 0) {
          // HTTP header has been send and Server response header has been handled
          Serial.printf("[HTTPS] GET... code: %d\n", httpCode);
 
          // file found at server
          if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
            String payload = https.getString();
            Serial.println(payload);
          }
        } else {
          Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
        }
 
        https.end();
      } else {
        Serial.printf("[HTTPS] Unable to connect\n");
      }

      // End extra scoping block
    }
 
    delete client;
  } else {
    Serial.println("Unable to create client");
  }

  Serial.println();
  Serial.println("Waiting 10s before the next round...");
  delay(10000);
}
 

kotyara12

New member
Что у вас там в rootCACertificate?
Код:
// This is GandiStandardSSLCA2.pem, the root Certificate Authority that signed
// the server certifcate for the demo server https://jigsaw.w3.org in this
// example. This certificate is valid until Sep 11 23:59:59 2024 GMT
const char* rootCACertificate = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIF6TCCA9GgAwIBAgIQBeTcO5Q4qzuFl8umoZhQ4zANBgkqhkiG9w0BAQwFADCB\n" \
"iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" \
"cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" \
"BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTQw\n" \
"OTEyMDAwMDAwWhcNMjQwOTExMjM1OTU5WjBfMQswCQYDVQQGEwJGUjEOMAwGA1UE\n" \
"CBMFUGFyaXMxDjAMBgNVBAcTBVBhcmlzMQ4wDAYDVQQKEwVHYW5kaTEgMB4GA1UE\n" \
"AxMXR2FuZGkgU3RhbmRhcmQgU1NMIENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" \
"DwAwggEKAoIBAQCUBC2meZV0/9UAPPWu2JSxKXzAjwsLibmCg5duNyj1ohrP0pIL\n" \
"m6jTh5RzhBCf3DXLwi2SrCG5yzv8QMHBgyHwv/j2nPqcghDA0I5O5Q1MsJFckLSk\n" \
"QFEW2uSEEi0FXKEfFxkkUap66uEHG4aNAXLy59SDIzme4OFMH2sio7QQZrDtgpbX\n" \
"bmq08j+1QvzdirWrui0dOnWbMdw+naxb00ENbLAb9Tr1eeohovj0M1JLJC0epJmx\n" \
"bUi8uBL+cnB89/sCdfSN3tbawKAyGlLfOGsuRTg/PwSWAP2h9KK71RfWJ3wbWFmV\n" \
"XooS/ZyrgT5SKEhRhWvzkbKGPym1bgNi7tYFAgMBAAGjggF1MIIBcTAfBgN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n" \
"KA5R2d4On3XNDgOVyvnFqSot/kGkoUeuDcL5OWYzSlvhhChZbH2UF3bkRYKtcCD9\n" \
"0m9jqNf6oDP6N8v3smWe2lBvP+Sn845dWDKXcCMu5/3EFZucJ48y7RetWIExKREa\n" \
"m9T8bJUox04FB6b9HbwZ4ui3uRGKLXASUoWNjDNKD/yZkuBjcNqllEdjB+dYxzFf\n" \
"BT02Vf6Dsuimrdfp5gJ0iHRc2jTbkNJtUQoj1iM=\n" \
"-----END CERTIFICATE-----\n";
Сертификат, разумеется. Это стандартный пример: c:\Users\Odmin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.3\libraries\HTTPClient\examples\BasicHttpsClient\

Должен же пример работать по умолчанию или что это за пример??????
 

kotyara12

New member
В общем, оказалось это баг в версии 1.0.3 arduino-esp32. на 1.0.2 все работает.
 
Сверху Снизу