GithubHelp home page GithubHelp logo

openslab-osu / sslclient Goto Github PK

View Code? Open in Web Editor NEW
145.0 14.0 46.0 1.83 MB

🔒Add SSL/TLS functionality to any Arduino library

Home Page: https://openslab-osu.github.io/SSLClient/index.html

License: GNU General Public License v3.0

C++ 3.07% C 95.91% Python 1.02%
sslclient arduino-library tls bearssl internet-of-things arduino mtls

sslclient's Introduction

SSLClient

CI

SSLClient adds TLS 1.2 functionality to any network library implementing the Arduino Client interface, including the Arduino EthernetClient and WiFiClient classes. SSLClient was created to integrate TLS seamlessly with the Arduino infrastructure using BearSSL as an underlying TLS engine. Unlike ArduinoBearSSL, SSLClient is completly self-contained, and does not require any additional hardware (other than a network connection).

SSLClient officially supports SAMD21, SAM3X, ESP32, TIVA C, STM32F7, and Teensy >= 3.0; but it should work on any board with at least 110kB flash and 7kB RAM. SSClient does not currently support ESP8266 (see this issue) or AVR due to memory constraints on both platforms.

You can also view this README in doxygen.

Overview

Using SSLClient is similar to using any other Arduino-based Client class, as this library was developed around compatibility with EthernetClient. There are a few extra things, however, that you will need to get started:

  1. Board and Network Peripheral - Your board should have a lot of resources (>110kB flash and >7kB RAM), and your network peripheral should have a large internal buffer (>7kB). This library was tested with the Adafruit Feather M0 (256K flash, 32K RAM) and the Adafruit Ethernet Featherwing (16kB Buffer), and we still had to modify the Arduino Ethernet library to support larger internal buffers per socket (see the Implementation Gotchas).
  2. Trust Anchors - You will need a header containing array of trust anchors (example), which are used to verify the SSL connection later on. This file must generated for every project. Check out TrustAnchors.md on how to generate this file for your project, and for more information about what a trust anchor is.
  3. Network Peripheral Driver Implementing Client - Examples include EthernetClient, WiFiClient, and so on—SSLClient will run on top of any network driver exposing the Client interface.
  4. Analog Pin - Used for generating random data at the start of the connection (see the Implementation Gotchas).

Once all those are ready, you can create an SSLClient object like this:

BaseClientType baseClientInstance;
SSLClient client(baseClientInstance, TAs, (size_t)TAs_NUM, AnalogPin);

Where:

  • BaseClientType - The type of baseClientInstance
  • BaseClientInstance - An instance of the class you are using for SSLClient (the class associated with the network interface, from step 3). It is important that this instance be stored outside the SSLClient declaration (for instance, SSLClient(BaseClientType() ...) wouldn't work).
  • TAs - The name of the trust anchor array created in step 2. If you generated a header using the tutorial this will probably be TAs.
  • TAs_NUM - The number of trust anchors in TAs. If you generated a header using the tutorial this will probably be TAs_NUM.
  • AnalogPin - The analog pin to pull random data from (step 4).

For example, if I am using EthernetClient, a generated array of 2 trust anchors, and the analog pin A7, I would declare an SSLClient instance using:

EthernetClient baseClient;
SSLClient client(baseClient, TAs, 2, A7);

Given this client, simply use SSLClient as you would the base client class:

// connect to ardiuino.cc over ssl (port 443 for websites)
client.connect("www.arduino.cc", 443);
// Make a HTTP request
client.println("GET /asciilogo.txt HTTP/1.1");
client.println("User-Agent: AdafruitFeatherM0WiFi");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
client.flush();
// read and print the data
...

Note: client.connect("www.arduino.cc", 443) can take 5-15 seconds to finish on some low-power devices. This an unavoidable consequence of the SSL protocol, and is detailed more in Implementation Gotchas.

For more information on SSLClient, check out the examples, API documentation, or the rest of this README.

Other Features

Logging

SSLClient also allows for changing the debugging level by adding an additional parameter to the constructor:

EthernetClient baseClient;
SSLClient client(baseClient, TAs, (size_t)2, A7, 1, SSLClient::SSL_INFO);

Logging is always outputted through the Arduino Serial interface, so you'll need to setup Serial before you can view the SSL logs. Log levels are enumerated in ::DebugLevel. The log level is set to SSL_WARN by default.

Errors

When SSLClient encounters an error, it will attempt to terminate the SSL session gracefully if possible, and then close the socket. Simple error information can be found from SSLClient::getWriteError, which will return a value from the ::Error enum. For more detailed diagnostics, you can look at the serial logs, which will be displayed if the log level is at SSL_ERROR or lower.

Write Buffering

As you may have noticed in the documentation for SSLClient::write, calling this function does not actually write to the network. Instead, you must call SSLClient::available or SSLClient::flush, which will detect that the buffer is ready and write to the network (see SSLClient::write for details).

This was implemented as a buffered function because examples in Arduino libraries will often write to the network like so:

EthernetClient client;
// ...
// connect to ardiuino.cc over ssl (port 443 for websites)
client.connect("www.arduino.cc", 443);
// ...
// write an http request to the network
client.write("GET /asciilogo.txt HTTP/1.1\r\n");
client.write("Host: arduino.cc\r\n");
client.write("Connection: close\r\n");
// wait for response
while (!client.available()) { /* ... */ }
// ...

Notice that every single client.write() call immediately writes to the network. This behavior is fine for most network clients; with SSL, however, it results in many small encryption tasks that consume resources. To reduce the overhead of an SSL connection, SSLClient::write implicitly buffers until the developer states that they are waiting for data to be received with SSLClient::available. A simple example can be found below:

EthernetClient baseClient;
SSLClient client(baseClient, TAs, (size_t)2, A7);
// ...
// connect to ardiuino.cc over ssl (port 443 for websites)
client.connect("www.arduino.cc", 443);
// ...
// add http request to the buffer
client.write("GET /asciilogo.txt HTTP/1.1\r\n");
client.write("Host: arduino.cc\r\n");
client.write("Connection: close\r\n");
// write the bytes to the network, then wait for response
while (!client.available()) { /* ... */ }
// ...

If you would like to trigger a network write manually without using the SSLClient::available, you can also call SSLClient::flush, which will write all data and return when finished.

Session Caching

As detailed in the resources section, SSL handshakes take an extended period (1-4sec) to negotiate. BearSSL is able to keep a SSL session cache of the clients it has connected to which can drastically reduce this time: if BearSSL successfully resumes an SSL session, connection time is typically 100-500ms.

In order to use SSL session resumption:

  • The website you are connecting to must support it. Support is widespread, and you can verify it using SSLLabs.
  • You must reuse the same SSLClient object (SSL Sessions are stored in the object itself).
  • You must reconnect to the exact same server (detailed below).

NOTE: SSLClient automatically stores an IP address and hostname in each session, ensuring that if you call connect("www.google.com") SSLClient will use the same SSL session for that hostname. Unfortunately some websites have multiple servers on a single IP address (github.com being an example), so you may find that even if you are connecting to the same host the connection will not resume. This is a flaw in the SSL session protocol—though it has been resolved in TLS 1.3, the lack of widespread adoption of the new protocol prevents it from being resolved here.

SSL sessions can also expire based on server criteria (ex. timeout), which will result in a standard 4-10 second connection.

SSL sessions take memory to store, so by default SSLClient will only store one at a time. You can change this behavior by adding the following to your SSLClient declaration:

EthernetClient baseClient;
SSLClient client(baseClient, TAs, (size_t)2, A7, SomeNumber);

Where SomeNumber is the number of sessions you would like to store. For example this declaration can store 3 sessions:

EthernetClient baseClient;
SSLClient client(baseClient, TAs, (size_t)2, A7, 3);

Sessions are managed internally using the SSLSession::getSession function. This function will cycle through sessions in a rotating order, allowing the session cache to continually overwrite old sessions. In general, it is a good idea to use a SessionCache size equal to the number of domains you plan on connecting to.

If you need to clear a session, you can do so using the SSLSession::removeSession function.

mTLS

As of v1.6.0, SSLClient supports mutual TLS authentication. mTLS is a varient of TLS that verifies both the server and device identities before a connection, and is commonly used in IoT protocols as a secure layer (MQTT over TLS, HTTP over TLS, etc.).

To use mTLS with SSLClient you will need to a client certificate and client private key associated with the server you are attempting to connect to. Depending on your use case, you will either generate these yourself (ex. Mosquito MQTT setup), or have them generated for you (ex. AWS IoT Certificate Generation). Given this cryptographic information, you can modify the standard SSLClient connection sketch to enable mTLS authentication:

...
/* Somewhere above setup() */

// The client certificate, can be PEM or DER format
// DER format will be an array of raw bytes, and PEM format will be a string
// PEM format is shown below
const char my_cert[] = 
"-----BEGIN CERTIFICATE-----\n"
"MIIDpDCCAowCCQC7mCk5Iu3YmDANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UEBhMC\n"
...
"-----END CERTIFICATE-----\n";

// The client private key, must be the same format as the client certificate
// Both RSA and ECC are supported, ECC is shown below
const char my_key[] = 
"-----BEGIN EC PRIVATE KEY-----\n"
...
"-----END EC PRIVATE KEY-----\n";

// This line will parse and store the above information so SSLClient can use it later
// Replace `fromPEM` with `fromDER` if you are using DER formatted certificates.
SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof(cert), my_key, sizeof(key));
SSLClient my_client(...);
...
void setup() {
    ...
    /* Before SSLClient connects */

    my_client.setMutualAuthParams(mTLS);
    ...
}
...

NOTE: Certificates are finicky, and it is easy to make mistakes when generating a certificate chain yourself. If SSLClient raises an error that says Expected server name not found in chain, double check that the common name, distinguished name, and issuer name are being set correctly (check out this article for how to do that).

The client certificate must be formatted correctly (according to BearSSL's specification) in order for mTLS to work. If the certificate is improperly formatted, SSLClient will attempt to make a regular TLS connection instead of an mTLS one, and fail to connect as a result. Because of this, if you are seeing errors similar to "peer did not send certificate chain" on your server, check that your certificate and key are formatted correctly (see #7 (comment)). For more information on SSLClient's mTLS functionality, please see the SSLClientParameters documentation.

Note that both the above client certificate information as well as the correct trust anchors associated with the server are needed for the connection to succeed. Trust anchors will typically be generated from the CA used to generate the server certificate. More information on generating trust anchors can be found in TrustAnchors.md.

Implementation Gotchas

Some ideas that didn't quite fit in the API documentation.

SSLClient with Ethernet

If you are using the Arduino Ethernet library you will need to modify the library to support the large buffer sizes required by SSL (detailed in resources). You can either modify the library yourself, or use this fork of the Ethernet library with the modification. To use the fork: download a zipped copy of the fork through GiThub, use the "add a .zip library" button in Arduino to install the library, and replace #include "Ethernet.h" with #include "EthernetLarge.h" in your sketch. Alternatively if for some reason this solution does not work, you can apply the modification manually using the instructions below.

Manual Modification

First find the location of the library in the directory where Arduino is installed (C:\Program Files (x86)\Arduino on Windows). Inside of this directory, navigate to libraries\Ethernet\src (C:\Program Files (x86)\Arduino\libraries\Ethernet\src on Windows). Modify Ethernet.h to replace these lines:

...
// Configure the maximum number of sockets to support.  W5100 chips can have
// up to 4 sockets.  W5200 & W5500 can have up to 8 sockets.  Several bytes
// of RAM are used for each socket.  Reducing the maximum can save RAM, but
// you are limited to fewer simultaneous connections.
#if defined(RAMEND) && defined(RAMSTART) && ((RAMEND - RAMSTART) <= 2048)
#define MAX_SOCK_NUM 4
#else
#define MAX_SOCK_NUM 8
#endif

// By default, each socket uses 2K buffers inside the Wiznet chip.  If
// MAX_SOCK_NUM is set to fewer than the chip's maximum, uncommenting
// this will use larger buffers within the Wiznet chip.  Large buffers
// can really help with UDP protocols like Artnet.  In theory larger
// buffers should allow faster TCP over high-latency links, but this
// does not always seem to work in practice (maybe Wiznet bugs?)
//#define ETHERNET_LARGE_BUFFERS
...

With this:

...
// Configure the maximum number of sockets to support.  W5100 chips can have
// up to 4 sockets.  W5200 & W5500 can have up to 8 sockets.  Several bytes
// of RAM are used for each socket.  Reducing the maximum can save RAM, but
// you are limited to fewer simultaneous connections.
#define MAX_SOCK_NUM 2

// By default, each socket uses 2K buffers inside the Wiznet chip.  If
// MAX_SOCK_NUM is set to fewer than the chip's maximum, uncommenting
// this will use larger buffers within the Wiznet chip.  Large buffers
// can really help with UDP protocols like Artnet.  In theory larger
// buffers should allow faster TCP over high-latency links, but this
// does not always seem to work in practice (maybe Wiznet bugs?)
#define ETHERNET_LARGE_BUFFERS
...

You may need to use sudo or administrator permissions to make this modification. We change MAX_SOCK_NUM and ETHERNET_LARGE_BUFFERS so the Ethernet hardware can allocate a larger space for SSLClient, however a downside of this modification is we are now only able to have two sockets concurrently. As most microprocessors barely have enough memory for one SSL connection, this limitation will rarely be encountered in practice.

Seeding Random Data

The SSL protocol requires that SSLClient generate some random bits before connecting with a server. BearSSL provides a random number generator but requires a some entropy for a seed. Normally this seed is generated by taking the microsecond time using the internal clock, however since most microcontrollers are not build with this feature another source must be found. As a simple solution, SSLClient uses a floating analog pin as an external source of random data, passed through to the constructor in the analog_pin argument. Before every connection, SSLClient will take the bottom byte from 16 analog reads on analog_pin, and combine these bytes into a 16 byte random number, which is used as a seed for BearSSL. To ensure the most random data, it is recommended that this analog pin be either floating or connected to a location not modifiable by the microcontroller (i.e. a battery voltage readout).

Certificate Verification

SSLClient uses BearSSL's minimal x509 verification engine to verify the certificate of an SSL connection. This engine requires the developer create a trust anchor array using values stored in trusted root certificates. Check out this document for more details on this component of SSLClient.

BearSSL also features a known certificate validation engine, which only allows for a single domain in exchange for a significantly reduced resource usage (flash and CPU time). This functionality is planned to be implemented in the future.

Time

The minimal x509 verification engine requires an accurate source of time to properly verify the creation and expiration dates of a certificate. As most embedded devices do not have a reliable source of time, by default SSLClient opts to use the compilation timestamp (__DATE__ and __TIME__) as the "current time" during the verification process. While this approach reduces the complexity of using SSLClient, it is inherently insecure, and can cause errors if certificates are redeployed (see #27): to accommodate these edge cases, SSLClient::setVerificationTime can be used to update the timestamp before connecting, resolving the above issues.

Resources

The SSL/TLS protocol recommends a device support many different encryption and handshake algorithms. The complexity of these components results in many medium-footprint algorithms forming an extremely large whole. Compilation size of the EthernetHTTPS example in SSLClient v1.6.11 for various boards is shown below:

Board Size
Arduino Zero
RAM:   [===       ]  33.7% (used 11052 bytes from 32768 bytes)
Flash: [=== ] 34.7% (used 90988 bytes from 262144 bytes)
Arduino Due
RAM:   [=         ]  11.7% (used 11548 bytes from 98304 bytes)
Flash: [== ] 16.7% (used 87572 bytes from 524288 bytes)
Adafruit Feather M0
RAM:   [====      ]  40.4% (used 13240 bytes from 32768 bytes)
Flash: [==== ] 40.0% (used 104800 bytes from 262144 bytes)
ESP32 (Lolin32)
RAM:   [=         ]   6.9% (used 22476 bytes from 327680 bytes)
Flash: [== ] 24.0% (used 314956 bytes from 1310720 bytes)
Teensy 3.0
RAM:   [========  ]  78.2% (used 12812 bytes from 16384 bytes)
Flash: [======== ] 79.8% (used 104532 bytes from 131072 bytes)
Teensy 3.1
RAM:   [==        ]  19.9% (used 13020 bytes from 65536 bytes)
Flash: [==== ] 40.6% (used 106332 bytes from 262144 bytes)
Teensy 3.5
RAM:   [          ]   5.0% (used 12996 bytes from 262136 bytes)
Flash: [== ] 20.1% (used 105476 bytes from 524288 bytes)
Teensy 3.6
RAM:   [          ]   5.0% (used 13060 bytes from 262144 bytes)
Flash: [= ] 10.2% (used 106828 bytes from 1048576 bytes)
Teensy 4.0
RAM:   [===       ]  25.9% (used 135860 bytes from 524288 bytes)
Flash: [= ] 5.7% (used 115344 bytes from 2031616 bytes)
STM32F401CC
RAM:   [==        ]  19.8% (used 12944 bytes from 65536 bytes)
Flash: [==== ] 37.6% (used 98552 bytes from 262144 bytes)
STM32F411CE
RAM:   [=         ]   9.9% (used 12944 bytes from 131072 bytes)
Flash: [== ] 18.8% (used 98784 bytes from 524288 bytes)

In addition to the above, most embedded processors lack the sophisticated math hardware commonly found in a modern CPU, which results in slow and memory intensive execution of these algorithms. Because of this, it is recommended that SSLClient have 8kb of memory available on the stack during a connection, and 4-10 seconds should be allowed for the connection to complete. Note that this requirement is based on the SAMD21—more powerful processors (such as the ESP32) will see faster connection times.

NOTE: If flash footprint is becoming a problem, there are numerous debugging strings (~3kB estimated) that can be removed from SSLClient.h, SSLClientImpl.h, and SSLClientImpl.cpp. Unfortunately I have not figured out a way to configure compilation of these strings, so you will need to modify the library to remove them yourself.

Read Buffer Overflow

SSL is a buffered protocol, and since most microcontrollers have limited resources (see Resources), SSLClient is limited in the size of its buffers. A common problem I encountered with SSL connections is buffer overflow caused by the server sending too much data at once. This problem is caused by the microcontroller being unable to copy and decrypt data faster than it is being received—forcing some data to be discarded. This usually puts BearSSL in an unrecoverable state, forcing SSLClient to close the connection with a write error. If you are experiencing frequent timeout problems this could be the reason why.

In order to remedy this problem, the device must be able to read the data faster than it is being received or have a cache large enough to store the entire payload. Since the device is typically already reading as fast as it can, we must increase the cache size in order to resolve this issue. Depending on your platform there are a number of ways this can be done:

  • Sometimes your communication shield will have an internal buffer which can be expanded through the driver code: this is the case with the Arduino Ethernet library (in the form of the MAX_SOCK_NUM and ETHERNET_LARGE_BUFFERS macros show here), but mileage may vary with other drivers.
  • SSLClient has an internal buffer SSLClient::m_iobuf which can be expanded. Unfortunately, BearSSL limits the amount of data that can be put into the buffer based on the stage in the SSL handshake, and so increasing the buffer will have limited usefulness.
  • In some cases, a website will send so much data that even with the above solutions SSLClient will be unable to keep up. In these cases you will have to find another method of retrieving the data you need.
  • If none of the above are viable, it is possible to implement your own Client class which has an internal buffer much larger than both the driver and BearSSL. This implementation would require in-depth knowledge of communication shield you are working with and a microcontroller with a significant amount of RAM, but would be the most robust solution available.

Cipher Support

By default, SSLClient supports only TLS1.2 and the ciphers listed in this file under suites[], and the list is relatively small to keep the connection secure and the flash footprint down. These ciphers should work for most applications, however if for some reason you would like to use an older version of TLS or a different cipher you can change the BearSSL profile being used by SSLClient to an alternate one with support for older protocols. To do this, edit SSLClientImpl::SSLClientImpl to change these lines:

br_client_init_TLS12_only(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);
// comment the above line and uncomment the line below if you're having trouble connecting over SSL
// br_ssl_client_init_full(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);

to this:

// br_client_init_TLS12_only(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);
// comment the above line and uncomment the line below if you're having trouble connecting over SSL
br_ssl_client_init_full(&m_sslctx, &m_x509ctx, m_trust_anchors, m_trust_anchors_num);

If for some unfortunate reason you need SSL 3.0 or SSL 2.0, you will need to modify the BearSSL profile to enable support. Check out the BearSSL profiles documentation and I wish you the best of luck.

Security

Unlike BearSSL, SSLClient is not rigorously vetted to be secure. If your project has security requirements I recommend you utilize BearSSL directly.

Known Issues

  • In some drivers (Ethernet), calls to Client::flush will hang if internet is available but there is no route to the destination. Unfortunately SSLClient cannot correct for this without modifying the driver itself, and as a result the recommended solution is ensuring you choose a driver with built-in timeouts to prevent freezing. More information here.
  • Previous to SSLClient v1.6.11, SSLClient::write would sometimes call br_ssl_engine_sendapp_ack with zero bytes, which resulted in a variety of issues including (but not limited to) and infinite recursion loop on the esp32 (#9, #30).
  • Previous to SSLClient v1.6.7, calls to SSLClient::stop would sometimes hang the device. More information in issue #13.
  • Previous to SSLClient v1.6.6, calls to SSLClient::connect would fail if the driver indicated that a socket was already opened (Client::connected returned true). This behavior created unintentional permanent failures when Client::stop would fail to close the socket, and as a result was downgraded to a warning in v1.6.6.
  • Previous to SSLClient v1.6.3, calling SSLClient::write with more than 2kB of total data before flushing the write buffer would cause a buffer overflow.

sslclient's People

Contributors

amanenk avatar bigjohnson avatar bleckers avatar mirrorkeydev avatar prototypicalpro avatar xreef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sslclient's Issues

error: 'br_x509_trust_anchor' does not name a type

Hello,
I'm trying to implement mutual TLS on Nano 33 IoT board for MQTT communication. I generated the certificates.h using the pycert_bearssl.py tool but when I try to compile I got the following error:

certificates.h:60:14: error: 'br_x509_trust_anchor' does not name a type
 static const br_x509_trust_anchor TAs[] = {
              ^~~~~~~~~~~~~~~~~~~~
eggdome_sensor:40:30: error: 'TAs' was not declared in this scope
 SSLClient client(wifiClient, TAs, (size_t)TAs_NUM, A2);
                              ^~~
exit status 1
'br_x509_trust_anchor' does not name a type

Where is the br_x509_trust_anchor type supposed to be defined ? Is there a dependency I should include ?

Here is a code generating this error:

#include "arduino_secrets.h"

#include "certificates.h"
#include <SSLClient.h>

#include <ArduinoMqttClient.h>
#include <WiFiNINA.h>

/////// please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;    // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)

char mqttUser[] = SECRET_MQTT_USER;       // MQTT client username
char mqttPassword[] = SECRET_MQTT_PWD;    // MQTT client password

WiFiClient wifiClient;
SSLClient client(wifiClient, TAs, (size_t)TAs_NUM, A2);
MqttClient mqttClient(wifiClient);

const char  broker[] = "192.168.0.14";
int         port     = 8883;

void setup() {}

void loop() {}


Disconnection while receiving a large message

I'm not sure if this issue is related to SSLClient or to PubSubClient.
After subscribing to an MQTT topic, I can successfully receive messages. But if the message is "too large" I get a disconnection:

For example, the message I'm expecting from AWS ($aws/things/<thing>/shadow/get) is about 9 kbytes large. I've plenty of RAM on my STM32 so I added:

#define MQTT_PACKET_SIZE  16384

SSLClientParameters mTLS = SSLClientParameters::fromPEM(certificateBuff, sizeof certificateBuff, privateKeyBuff, sizeof privateKeyBuff);
EthernetClient ethClient;
SSLClient networkClient(ethClient, TAs, (size_t)TAs_NUM, A5);
PubSubClient mqtt(mqttServer, 8883, MQTT_Callback, networkClient);

void setup()
{
    ...
    mqtt.setBufferSize(MQTT_PACKET_SIZE);
    ...
}

My MQTT_Callback doesn't require a new buffer:

void MQTT_Callback(char *topic, byte *payload, unsigned int length)
{
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) Serial.print((char)payload[i]);
  Serial.println();
}

This is the output:

Arduino Log > 17:13:57.087 -> DHCP assigned IP 192.168.1.179 > 17:13:57.087 -> [NET] MAC Address: 00:80:E1:3E:00:40 > 17:13:58.576 -> Attempting MQTT connection...connected > 17:14:02.117 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:02.315 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:02.514 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:02.679 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:02.878 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:02.878 -> Published [$aws/things//shadow/get] > 17:14:03.043 -> Attempting MQTT connection...(SSLClient)(SSL_WARN)(connect): Arduino client is already connected? Continuing anyway... > 17:14:06.352 -> connected > 17:14:06.518 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:06.716 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:06.882 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:07.080 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:07.246 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:07.279 -> Published [$aws/things//shadow/get] > 17:14:07.411 -> Attempting MQTT connection...(SSLClient)(SSL_WARN)(connect): Arduino client is already connected? Continuing anyway... > 17:14:10.753 -> connected > 17:14:10.919 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:14:11.084 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > ... >

I also tried to enable logging, and this is the new output:

Arduino Log > DHCP assigned IP 192.168.1.179 > 17:18:45.719 -> [NET] MAC Address: 00:80:E1:3E:00:40 > 17:18:47.208 -> Attempting MQTT connection...(SSLClient)(SSL_INFO)(connect): Base client connected! > 17:18:47.406 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:47.406 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:47.406 -> RECVREC > 17:18:47.406 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:47.439 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:50.384 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.417 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.417 -> RECVREC > 17:18:50.417 -> SENDAPP > 17:18:50.417 -> (SSLClient)(SSL_INFO)(m_start_ssl): Connection successful! > 17:18:50.583 -> connected > 17:18:50.583 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.583 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.616 -> SENDAPP > 17:18:50.616 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.616 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.616 -> RECVREC > 17:18:50.616 -> SENDAPP > 17:18:50.616 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:50.616 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:50.781 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.781 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.781 -> RECVAPP > 17:18:50.781 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.781 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.781 -> RECVAPP > 17:18:50.781 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:50.815 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.815 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.815 -> RECVREC > 17:18:50.815 -> SENDAPP > 17:18:50.815 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:50.815 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:50.815 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.848 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.848 -> SENDAPP > 17:18:50.848 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:50.848 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:50.848 -> RECVREC > 17:18:50.848 -> SENDAPP > 17:18:50.848 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:50.848 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:50.980 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.013 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.013 -> RECVAPP > 17:18:51.013 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.013 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.013 -> RECVAPP > 17:18:51.013 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:51.046 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.046 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.046 -> RECVREC > 17:18:51.046 -> SENDAPP > 17:18:51.046 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:51.046 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:51.046 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.046 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.046 -> SENDAPP > 17:18:51.152 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.152 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.152 -> RECVREC > 17:18:51.152 -> SENDAPP > 17:18:51.152 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:51.152 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:51.311 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.311 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.311 -> RECVAPP > 17:18:51.311 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.311 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.344 -> RECVAPP > 17:18:51.344 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:51.344 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.344 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.344 -> RECVREC > 17:18:51.344 -> SENDAPP > 17:18:51.344 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:51.377 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:51.377 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.377 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.377 -> SENDAPP > 17:18:51.377 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.377 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.377 -> RECVREC > 17:18:51.377 -> SENDAPP > 17:18:51.377 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:51.410 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:51.542 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.542 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.542 -> RECVAPP > 17:18:51.542 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.542 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.542 -> RECVAPP > 17:18:51.542 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:51.575 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.575 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.575 -> RECVREC > 17:18:51.575 -> SENDAPP > 17:18:51.575 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:51.575 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:51.575 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.609 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.609 -> SENDAPP > 17:18:51.609 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.609 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.609 -> RECVREC > 17:18:51.609 -> SENDAPP > 17:18:51.609 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:51.609 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:51.774 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.774 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.774 -> RECVAPP > 17:18:51.774 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.774 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.774 -> RECVAPP > 17:18:51.774 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:51.807 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:51.807 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:51.807 -> RECVREC > 17:18:51.807 -> SENDAPP > 17:18:51.807 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:52.800 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:52.965 -> (SSLClient)(SSL_INFO)(available): Engine closed after update > 17:18:52.965 -> Attempting MQTT connection...(SSLClient)(SSL_WARN)(connect): Arduino client is already connected? Continuing anyway... > 17:18:53.098 -> (SSLClient)(SSL_INFO)(connect): Base client connected! > 17:18:53.098 -> (SSLClient)(SSL_INFO)(m_get_session_index): .iot.us-east-2.amazonaws.com > 17:18:53.131 -> (SSLClient)(SSL_INFO)(getSession): Using session index: > 17:18:53.131 -> (SSLClient)(SSL_INFO)(getSession): 0 > 17:18:53.131 -> (SSLClient)(SSL_INFO)(m_start_ssl): Set SSL session! > 17:18:53.131 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:53.131 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:53.164 -> RECVREC > 17:18:53.164 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:53.164 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:56.109 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.109 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.142 -> RECVREC > 17:18:56.142 -> SENDAPP > 17:18:56.142 -> (SSLClient)(SSL_INFO)(m_start_ssl): Connection successful! > 17:18:56.308 -> connected > 17:18:56.308 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.308 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.308 -> SENDAPP > 17:18:56.308 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.308 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.341 -> RECVREC > 17:18:56.341 -> SENDAPP > 17:18:56.341 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:56.341 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:56.473 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.473 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.473 -> RECVAPP > 17:18:56.473 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.473 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.506 -> RECVAPP > 17:18:56.506 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:56.506 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.506 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.506 -> RECVREC > 17:18:56.506 -> SENDAPP > 17:18:56.506 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:56.539 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:56.539 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.539 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.539 -> SENDAPP > 17:18:56.539 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.539 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.539 -> RECVREC > 17:18:56.539 -> SENDAPP > 17:18:56.539 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:56.572 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:56.705 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.705 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.705 -> RECVAPP > 17:18:56.705 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.705 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.738 -> RECVAPP > 17:18:56.738 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:56.738 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.738 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.738 -> RECVREC > 17:18:56.738 -> SENDAPP > 17:18:56.738 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:56.771 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:56.771 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.771 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.771 -> SENDAPP > 17:18:56.771 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.771 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.771 -> RECVREC > 17:18:56.771 -> SENDAPP > 17:18:56.804 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:56.804 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:56.936 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.936 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.936 -> RECVAPP > 17:18:56.936 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.969 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.969 -> RECVAPP > 17:18:56.969 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:56.969 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:56.969 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:56.969 -> RECVREC > 17:18:56.969 -> SENDAPP > 17:18:57.002 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:57.002 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:57.002 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.002 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.002 -> SENDAPP > 17:18:57.002 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.002 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.036 -> RECVREC > 17:18:57.036 -> SENDAPP > 17:18:57.036 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:57.036 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:57.168 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.168 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.201 -> RECVAPP > 17:18:57.201 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.201 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.201 -> RECVAPP > 17:18:57.201 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:57.201 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.201 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.234 -> RECVREC > 17:18:57.234 -> SENDAPP > 17:18:57.234 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:57.234 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:57.234 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.234 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.234 -> SENDAPP > 17:18:57.234 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.234 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.267 -> RECVREC > 17:18:57.267 -> SENDAPP > 17:18:57.267 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:57.267 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > 17:18:57.400 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.400 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.400 -> RECVAPP > 17:18:57.400 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.433 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.433 -> RECVAPP > 17:18:57.433 -> (SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor a write operation > 17:18:57.433 -> (SSLClient)(SSL_INFO)(m_run_until): m_run changed state: > 17:18:57.433 -> (SSLClient)(SSL_INFO)(m_run_until): State: > 17:18:57.433 -> RECVREC > 17:18:57.433 -> SENDAPP > 17:18:57.433 -> (SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: > 17:18:58.458 -> (SSLClient)(SSL_INFO)(m_run_until): 5 > ... >

Error writing to m_client on ESP32

Describe the bug
ESP32dev board with ec28j60 ethernet module.
Using UIPEthernet library.
EthernetHTTPS example works fine however my program returns this error.
Free heap memory before connection request is 226416.

To Reproduce
Send a request to an SSL endpoint using the hardware setup mentioned above.

Expected behavior
Return html content.

Screenshots/Serial Output
(SSLClient)(SSL_ERROR)(m_update_engine): Error writing to m_client
(SSLClient)(SSL_ERROR)(m_update_engine): 0
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
(SSLClient)(SSL_WARN)(m_run_until): Terminating with write error:
(SSLClient)(SSL_WARN)(m_run_until): 4
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0

Context (please complete the following information):
platform = espressif32
board = esp32dev
framework = arduino
uipethernet/UIPEthernet@^2.0.9
openslab-osu/SSLClient@^1.6.11
build_flags = -D BEARSSL_SSL_BASIC

OTA integration

Is your feature request related to a problem? Please describe.
I did a try to use the SSLClient with OTA instrument, available here: https://github.com/chrisjoyce911/esp32FOTA, but it was wholly based on Wifi and WifiSecure libs that is not the way of communication I need in.

Describe the solution you'd like
It would be perfect to get the OTA possibility added like introduced above library does, but having the end user free on physical communication device choice. I was unable to get worked the TinyGSM, SSLClient and esp32FOTA together, when the tandem of first two performed very well in another project.

AWS IOT with SIMCOM7600SA

Hello everyone. I am working with an ESP32 board, with a SIMCOM7600SA modem.

I am using the SSL Client library to connect to AWS IOT Core. But I have some problems with the stability of the connection.

In some moments I get these errors, sometimes in the first connection attempt. or also after a few minutes.

After a few attempts to reconnect, it works again.

(SSLClient)(SSL_ERROR)(connect): Failed to connect using m_client. Are you connected to the internet?
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_CONNECT_FAIL
[165043] ### Unhandled: ERROR

What could be the problem ? or is it normal?

Thanks

MQTT SSL possible?

I've been trying for a long time with a lot of things but I can't get it to work, I don't even know if it is possible.
I would like to connect to a MQTT broker via TLS/SSL. I'm using EthernetLarge, SSLClient and pubsubclient with a SAMD21 board. No compile problems, but when I try to connect this appears:

(SSLClient)(SSL_INFO)(connect): Base client connected!
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_run_until): State:
RECVREC
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count:
(SSLClient)(SSL_INFO)(m_run_until): 5
(SSLClient)(SSL_INFO)(m_update_engine): Memory:
(SSLClient)(SSL_INFO)(m_update_engine): 9791
(SSLClient)(SSL_INFO)(m_update_engine): Memory:
(SSLClient)(SSL_INFO)(m_update_engine): 9791
(SSLClient)(SSL_INFO)(m_update_engine): Memory:
(SSLClient)(SSL_INFO)(m_update_engine): 9791
(SSLClient)(SSL_INFO)(m_update_engine): Memory:
(SSLClient)(SSL_INFO)(m_update_engine): 9791
(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Chain could not be linked to a trust anchor.
[MQTT](KO!): -2
(SSLClient)(SSL_ERROR)(connect): Cannot have two connections at the same time! Please create another SSLClient instance.

And the last SSL_ERROR message keeps repeating. On my server side a new connection appears but nothing else (mosquitto).

Part of the Arduino code:
(...)
EthernetClient ethClient;
SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, A6, 1, SSLClient::SSL_INFO);
PubSubClient client(mqttServer, 8883, callback, ethClientSSL);
(...)
client.connect(clientId, usr, pass, willTopic, willQoS, willRetain, willMessage)

Any help will be very appreciated.

Expected server name was not found in the chain

I'm trying to setup mutual TLS on Arduino Nano 33 IoT for a MQTT connection (using this library for MQTT along with SSLClient) but I have this error:

(SSLClient)(SSL_ERROR)(available): Cannot operate on a closed SSL connection.
(SSLClient)(SSL_ERROR)(m_print_br_error): Expected server name was not found in the chain.

Here is how I implement the connection in the arduino code:

WiFiClient wifiClient;
SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof(my_cert), my_key, sizeof(my_key));
SSLClient my_client(wifiClient, TAs, (size_t)TAs_NUM, A2);
MqttClient mqttClient(my_client);

[...]

// set client session
mqttClient.setCleanSession(true);
mqttClient.setId("mcu_sensor_client" + String(millis()));
mqttClient.setKeepAliveInterval(60 * 1000L);
mqttClient.setUsernamePassword(mqttUser, mqttPassword);

// set lastWill message
strcpy(payload, STATUS_KO);
retain = true;
qos = QOS_STATUS;
mqttClient.beginWill(mcu_status_topic, strlen(payload), retain, qos);
mqttClient.print(payload);
mqttClient.endWill();

// try to connect
if (!mqttClient.connect(broker, port)) {
  Serial.print("MQTT connection failed! Error code = ");
  Serial.println(mqttClient.connectError());
  return mqttClient.connectError();
}
digitalWrite(LED_BUILTIN, LOW);
Serial.println("You're connected to the MQTT broker!");

I use a self signed certificate ca.crt and the mcu cert files mcu_sensor.pem and mcu_sensor.key. I check my certificate with :

  • openssl verify -CAfile ca.crt mcu_sensor.pem; output: mcu_sensor.pem: OK
  • with docker run -v {pwd}/mcu_sensor.pem:/certs/cert.pem -v {pwd}/mcu_sensor.key:/certs/key.pem -v {pwd}/ca.crt:/certs/cacerts.pem superseb/cert-check:latest 192.168.0.14 (as explained in this article pointed out by the doc) which output:
INFO: Found CN localhost
INFO: Found Subject Alternative Name(s) (SANs): 192.168.0.14 host.docker.internal localhost node1.emqx.io
OK: 192.168.0.14 was found in SANs (192.168.0.14 host.docker.internal localhost node1.emqx.io)
OK: Certificate and certificate key match
OK: Certificate chain is complete
INFO: Showing certificate chain from /certs/cert.pem
subject=/C=FR/ST=IleDeFrance/L=Paris/O=myCompany/CN=localhost
issuer=/C=FR/ST=IleDeFrance/L=Paris/O=myCompany/CN=local host

I really don't understand why it says server name not found ? Everything looks ok with my certificates

PS: I can share the certificates if it helps (I can re generate new ones after ;)

Support for Teensy 4.0 Boards

Is your feature request related to a problem? Please describe.
I was trying to connect to the AWS IOT from my teensy 4.0 board referring to issue #17 but after successful compilation i get a warning saying:

WARNING: library SSLClient claims to run on samd, sam, tivac, stm32, esp32 architecture(s) and may be incompatible with your current board which runs on avr architecture(s).

and the Command Window I get this error message:

Attempting MQTT connection...(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed

(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer

(SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 298

Describe the solution you'd like
I wanted to check if this library supports Teensy4.0 if not are there any similar ones that support teensy 4.0 boards.

Additional context
Teensy 4.0 features an ARM Cortex-M7 processor at 600 MHz, with a NXP iMXRT1062 chip. https://www.pjrc.com/store/teensy40.html

AWS MQTT ESP32 SIM800 TinyGSM

Firts of all, thanks a lot to contribute. :-)

I am trining to connecting to AWS IOT by MQTT. I am using Esp32 with SIM800L.
To manage SIM800L I am using TinyGSM library.
So I copied and paste your MQTT example, and tried with WIFI, and it works fine after some minor fix on the Ethernet library.
Now I added TinyGSM and removed WiFi but I got an error...

Partial important code changing here:

TinyGsm modem(SerialAT);
TinyGsmClient transport(modem);

SSLClient ethClientSSL(transport, TAs, (size_t)TAs_NUM, A5);
PubSubClient mqtt(mqttServer, 8883, callback, ethClientSSL);

I got this error:

Initializing modem...
[8304] ### TinyGSM Version: 0.10.9
[8304] ### TinyGSM Compiled Module:  TinyGsmClientSIM800
[8617] ### Modem: SIMCOM SIM800L
[8617] ### Modem: SIMCOM SIM800L
1
[NET] Signal quality before GPRS ( >10 OK ): 0
Modem Info: SIM800 R14.18
[29070] ### Network time zone updated.
[29073] ### Network time and time zone updated.
[29074] ### Daylight savings time state updated.
Waiting for network... success
Network connected
Attempting MQTT connection...(SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
(SSLClient)(SSL_ERROR)(m_update_engine): 0
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
(SSLClient)(SSL_WARN)(m_run_until): Terminating with write error: 
(SSLClient)(SSL_WARN)(m_run_until): 4
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
failed, rc=-2 try again in 5 seconds
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
Attempting MQTT connection...(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL

Am I doing something bad when I use that "transport(modem)" in this way?
There is any way to find where is the error?

PubSubClient on ESP32 overflows the stack

Working with @jhnwmr on #8 I discovered that the using PubSubClient with SSLClient causes a stack overflow on the ESP32:

Error Log
t.cpX:337] _eventCallback(): Event: 2 - STA_START
..[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 5 - STA_DISCONNECTED
[W][WiFiGeneric.cpp:353] _eventCallback(): Reason: 2 - AUTH_EXPIRE
....[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 5 - STA_DISCONNECTED
[W][WiFiGeneric.cpp:353] _eventCallback(): Reason: 201 - NO_AP_FOUND
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:381] _eventCallback(): STA IP: 192.168.137.94, MASK: 255.255.255.0, GW: 192.168.137.1
.Attempting MQTT connection...(SSLClient)(SSL_WARN)(connect): Using a raw IP Address for an SSL connection bypasses some important verification steps. You should use a domain name (www.google.com) whenever possible.
connected

Backtrace: 0x4c103f95:0x3ffbe160 0x229cfdfd:0x3ffbe180 0x40089037:0x3ffbe1a0 0x4008b74d:0x3ffbe1c0 0x40084b46:0x3ffbe1d0 0x4014a2df:0x3ffbc200 0x400e321b:0x3ffbc220 0x4008a72d:0x3ffbc240 0x40088f49:0x3ffbc260


Backtrace: 0x7dc000e6:0x7dc000e6

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
.[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:381] _eventCallback(): STA IP: 192.168.137.94, MASK: 255.255.255.0, GW: 192.168.137.1
.Attempting MQTT connection...(SSLClient)(SSL_WARN)(connect): Using a raw IP Address for an SSL connection bypasses some important verification steps. You should use a domain name (www.google.com) whenever possible.
connected

Backtrace: 0x78f076a5:0x3ffbe160 0x08a73f7d:0x3ffbe180 0x40089037:0x3ffbe1a0 0x4008b74d:0x3ffbe1c0 0x40084b46:0x3ffbe1d0 0x4014a2df:0x3ffbc200 0x400e321b:0x3ffbc220 0x4008a72d:0x3ffbc240 0x40088f49:0x3ffbc260


Backtrace: 0x4008c777:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0 0x4008c8f5:0x3ffbdfe0 0x4008c982:0x3ffbe060 0x4008cc75:0x3ffbe080 0x400848be:0x3ffbe0a0 0x78f076a2:0x3ffbe160


Backtrace: 0x4008c777:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20 0x4008c8f5:0x3ffbde40 0x4008c982:0x3ffbdec0 0x4008cc75:0x3ffbdee0 0x400848be:0x3ffbdf00 0x4008c774:0x3ffbdfc0


Backtrace: 0x4008c777:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80 0x4008c8f5:0x3ffbdca0 0x4008c982:0x3ffbdd20 0x4008cc75:0x3ffbdd40 0x400848be:0x3ffbdd60 0x4008c774:0x3ffbde20


Backtrace: 0x4008c777:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0 0x4008c8f5:0x3ffbdb00 0x4008c982:0x3ffbdb80 0x4008cc75:0x3ffbdba0 0x400848be:0x3ffbdbc0 0x4008c774:0x3ffbdc80


Backtrace: 0x4008c777:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940 0x4008c8f5:0x3ffbd960 0x4008c982:0x3ffbd9e0 0x4008cc75:0x3ffbda00 0x400848be:0x3ffbda20 0x4008c774:0x3ffbdae0


Backtrace: 0x4008c777:0x3ffbc900 0x4008c8f5:0x3ffbc920 0x4008c982:0x3ffbc9a0 0x4008cc75:0x3ffbc9c0 0x400848be:0x3ffbc9e0 0x4008c774:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0 0x4008c8f5:0x3ffbd7c0 0x4008c982:0x3ffbd840 0x4008cc75:0x3ffbd860 0x400848be:0x3ffbd880 0x4008c774:0x3ffbd940


Backtrace: 0x4008c777:0x3ffbc760 0x4008c8f5:0x3ffbc780 0x4008c982:0x3ffbc800 0x4008cc75:0x3ffbc820 0x400848be:0x3ffbc840 0x4008c774:0x3ffbc900 0x4008c8f5:0x3ffbc920 0x4008c982:0x3ffbc9a0 0x4008cc75:0x3ffbc9c0 0x400848be:0x3ffbc9e0 0x4008c774:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600 0x4008c8f5:0x3ffbd620 0x4008c982:0x3ffbd6a0 0x4008cc75:0x3ffbd6c0 0x400848be:0x3ffbd6e0 0x4008c774:0x3ffbd7a0


Backtrace: 0x4008c777:0x3ffbc5c0 0x4008c8f5:0x3ffbc5e0 0x4008c982:0x3ffbc660 0x4008cc75:0x3ffbc680 0x400848be:0x3ffbc6a0 0x4008c774:0x3ffbc760 0x4008c8f5:0x3ffbc780 0x4008c982:0x3ffbc800 0x4008cc75:0x3ffbc820 0x400848be:0x3ffbc840 0x4008c774:0x3ffbc900 0x4008c8f5:0x3ffbc920 0x4008c982:0x3ffbc9a0 0x4008cc75:0x3ffbc9c0 0x400848be:0x3ffbc9e0 0x4008c774:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460 0x4008c8f5:0x3ffbd480 0x4008c982:0x3ffbd500 0x4008cc75:0x3ffbd520 0x400848be:0x3ffbd540 0x4008c774:0x3ffbd600


Backtrace: 0x4008c777:0x3ffbc420 0x4008c8f5:0x3ffbc440 0x4008c982:0x3ffbc4c0 0x4008cc75:0x3ffbc4e0 0x400848be:0x3ffbc500 0x4008c774:0x3ffbc5c0 0x4008c8f5:0x3ffbc5e0 0x4008c982:0x3ffbc660 0x4008cc75:0x3ffbc680 0x400848be:0x3ffbc6a0 0x4008c774:0x3ffbc760 0x4008c8f5:0x3ffbc780 0x4008c982:0x3ffbc800 0x4008cc75:0x3ffbc820 0x400848be:0x3ffbc840 0x4008c774:0x3ffbc900 0x4008c8f5:0x3ffbc920 0x4008c982:0x3ffbc9a0 0x4008cc75:0x3ffbc9c0 0x400848be:0x3ffbc9e0 0x4008c774:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0 0x4008c8f5:0x3ffbd2e0 0x4008c982:0x3ffbd360 0x4008cc75:0x3ffbd380 0x400848be:0x3ffbd3a0 0x4008c774:0x3ffbd460


Backtrace: 0x4008c777:0x3ffbc280 0x4008c8f5:0x3ffbc2a0 0x4008c982:0x3ffbc320 0x4008cc75:0x3ffbc340 0x400848be:0x3ffbc360 0x4008c774:0x3ffbc420 0x4008c8f5:0x3ffbc440 0x4008c982:0x3ffbc4c0 0x4008cc75:0x3ffbc4e0 0x400848be:0x3ffbc500 0x4008c774:0x3ffbc5c0 0x4008c8f5:0x3ffbc5e0 0x4008c982:0x3ffbc660 0x4008cc75:0x3ffbc680 0x400848be:0x3ffbc6a0 0x4008c774:0x3ffbc760 0x4008c8f5:0x3ffbc780 0x4008c982:0x3ffbc800 0x4008cc75:0x3ffbc820 0x400848be:0x3ffbc840 0x4008c774:0x3ffbc900 0x4008c8f5:0x3ffbc920 0x4008c982:0x3ffbc9a0 0x4008cc75:0x3ffbc9c0 0x400848be:0x3ffbc9e0 0x4008c774:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120 0x4008c8f5:0x3ffbd140 0x4008c982:0x3ffbd1c0 0x4008cc75:0x3ffbd1e0 0x400848be:0x3ffbd200 0x4008c774:0x3ffbd2c0


Backtrace: 0x4008c777:0x3ffbc0e0 0x4008c8f5:0x3ffbc100 0x4008c982:0x3ffbc180 0x4008cc75:0x3ffbc1a0 0x400848be:0x3ffbc1c0 0x4008c774:0x3ffbc280 0x4008c8f5:0x3ffbc2a0 0x4008c982:0x3ffbc320 0x4008cc75:0x3ffbc340 0x400848be:0x3ffbc360 0x4008c774:0x3ffbc420 0x4008c8f5:0x3ffbc440 0x4008c982:0x3ffbc4c0 0x4008cc75:0x3ffbc4e0 0x400848be:0x3ffbc500 0x4008c774:0x3ffbc5c0 0x4008c8f5:0x3ffbc5e0 0x4008c982:0x3ffbc660 0x4008cc75:0x3ffbc680 0x400848be:0x3ffbc6a0 0x4008c774:0x3ffbc760 0x4008c8f5:0x3ffbc780 0x4008c982:0x3ffbc800 0x4008cc75:0x3ffbc820 0x400848be:0x3ffbc840 0x4008c774:0x3ffbc900 0x4008c8f5:0x3ffbc920 0x4008c982:0x3ffbc9a0 0x4008cc75:0x3ffbc9c0 0x400848be:0x3ffbc9e0 0x4008c774:0x3ffbcaa0 0x4008c8f5:0x3ffbcac0 0x4008c982:0x3ffbcb40 0x4008cc75:0x3ffbcb60 0x400848be:0x3ffbcb80 0x4008c774:0x3ffbcc40 0x4008c8f5:0x3ffbcc60 0x4008c982:0x3ffbcce0 0x4008cc75:0x3ffbcd00 0x400848be:0x3ffbcd20 0x4008c774:0x3ffbcde0 0x4008c8f5:0x3ffbce00 0x4008c982:0x3ffbce80 0x4008cc75:0x3ffbcea0 0x400848be:0x3ffbcec0 0x4008c774:0x3ffbcf80 0x4008c8f5:0x3ffbcfa0 0x4008c982:0x3ffbd020 0x4008cc75:0x3ffbd040 0x400848be:0x3ffbd060 0x4008c774:0x3ffbd120

Guru Meditation Error: Core  0 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (8) 

This error persists despite increasing the stack size to >16kb, suggesting that this error is not simply due to a shortage of memory. My best guess is a bug in the BearSSL implementation of the ChaCha/Poly cipher suite, however it is too early so say for sure.

This error can temporarily be worked around by flushing SSLClient's buffer using SSLClient::flush after every write to the network. I have updated the examples to include this workaround, however It would definitely be best if this issue was addressed with a more permanent fix for the future.

EthernetHTTPS doesn't compile with AZ3166

Hi,

I'm trying to utilize the SSLClient with the AZ3166WiFiClient for the MXChip. But When I try to compile the code I keep getting an error stating:
fatal error: Client.h: No such file or directory

In my c_cpp_properties.json file I've listed "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/**" to the includePath which has the Client.h

Is there something wrong that I'm doing or can this library be even utilized for AZ3166 MXCHIP?

Thanks!

Email

Can you add one example for send email ?
Tls smtp
W5500
SAMD21

How to convert Distinguished Name in hex

How is this hex code generated, can anybody explain me?

static const unsigned char TA_DN0[] = {
    0x30, 0x3f, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13,
    0x1b, 0x44, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x53, 0x69, 0x67,
    0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74,
    0x20, 0x43, 0x6f, 0x2e, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04,
    0x03, 0x13, 0x0e, 0x44, 0x53, 0x54, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20,
    0x43, 0x41, 0x20, 0x58, 0x33,
};

If I convert this to ASCI my output is:
0?1$0"��U� ��Digital Signature Trust Co.1�0���U����DST Root CA X3

Some strange characters inside string I don't know what it means.

Also I try to use https://openslab-osu.github.io/bearssl-certificate-utility/ but it won't work for my subdomain, keep saying that I need to add domain, so I need logic how in this case this application transform those informations into hex generated code.

Not connected because write error is set

Describe the bug
MQTT does not connect, it seems to be conected to the internet, I have an IP and all, but it does not connect, Im using Arduino Due with Ethernet Shield, trying to connecto to amazon AWS IoT, ("Certificates already in the code, added trusted anchor generated in this page. https://openslab-osu.github.io/bearssl-certificate-utility/ ")

To Reproduce
Write some steps to reproduce the behavior. Be sure to include the vant hardware required, if any.
1.- Program Arduino Due with this code.

#include <SPI.h>
#include "secrets.h"
#include <EthernetLarge.h>
#include <PubSubClient.h>
#include <SSLClient.h>
#include "AWS_Root_CA.h"

#define RELAY1 7
#define RELAY2 3
#define RELAY3 5
#define RELAY4 6

/************ Ethernet Conection Information ******************/

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x78, 0xEE  };

/************ MQTT Information (CHANGE THESE FOR YOUR SETUP) ******************/
const int mqtt_port = 1883;

/**************************** FOR OTA **************************************************/
//#define SENSORNAME "vending_games_test" //change this to whatever you want to call your device

/************* MQTT TOPICS (change these topics as you wish)  **************************/
const char* light_state_topic = "arn:aws:iot:us-east-2:098230263297:topic/topic_1";
const char* light_set_topic = "arn:aws:iot:us-east-2:098230263297:topic/topic_1";

const char* on_cmd = "1";
const char* off_cmd = "0";

#define MQTT_MAX_PACKET_SIZE 512

char publishPayload[MQTT_MAX_PACKET_SIZE];

SSLClientParameters mTLS = SSLClientParameters::fromPEM(AWS_CERT_CRT, sizeof AWS_CERT_CRT, AWS_CERT_PRIVATE, sizeof AWS_CERT_PRIVATE);

EthernetClient ethClient;
SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, A5);
PubSubClient mqtt(ethClientSSL);

void setup() {
  Serial.begin(115200);
  
  pinMode(RELAY1,OUTPUT);
  pinMode(RELAY2,OUTPUT);
  pinMode(RELAY3,OUTPUT);
  pinMode(RELAY4,OUTPUT);
  
  pinMode(LED_BUILTIN, OUTPUT);

  ethClientSSL.setMutualAuthParams(mTLS);

  //mqtt.setClient(ethClient);
  mqtt.setServer(AWS_IOT_ENDPOINT, mqtt_port);
  mqtt.setCallback(callback);
  mqtt.setBufferSize(MQTT_MAX_PACKET_SIZE);
  
  setup_ethernet();

  delay(300);

  reconnect();
  
  Serial.println("Ready");
}

void setup_ethernet() {
  
  Ethernet.init(10);
  Ethernet.begin(mac);
  
  Serial.println("");
  Serial.println("IP address: ");
  Serial.println(Ethernet.localIP());

  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
  digitalWrite(LED_BUILTIN, HIGH);
}

/********************************** START CALLBACK*****************************************/
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");

  char message[length + 1];
  for (int i = 0; i < length; i++) {
    message[i] = (char)payload[i];
  }
  message[length] = '\0';
  Serial.println(message);

  int relay = atoi(message);
  switch(relay){
    case 1:
      pulse(RELAY1);
      break;
    case 2:
      pulse(RELAY2);
      break;
    case 3:
      pulse(RELAY3);
      break;
    case 4:
      pulse(RELAY4);
      break;
  }

  mqtt.publish(light_state_topic, message, true);

  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
  digitalWrite(LED_BUILTIN, HIGH);
}

void pulse(int relay) {
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
  digitalWrite(relay, HIGH);
  delay(300);
  digitalWrite(relay, LOW);
}

/********************************** START RECONNECT*****************************************/
void reconnect() {
  Serial.print("Attempting MQTT connection...");
  // Attempt to connect
  if (mqtt.connect(THINGNAME)) {
    Serial.println("connected");
    mqtt.subscribe(light_set_topic);
    updateThing();
    digitalWrite(LED_BUILTIN, HIGH);
    delay(100);
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
    digitalWrite(LED_BUILTIN, HIGH);
    delay(100);
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
    digitalWrite(LED_BUILTIN, HIGH);
  } else {
    Serial.print("failed, rc=");
    Serial.print(mqtt.state());
    Serial.println(" try again in 5 seconds");
    // Wait 5 seconds before retrying
    delay(5000);
  }
}

void updateThing()
{
  strcpy(publishPayload, "{\"state\": {\"reported\": {\"powerState\":\"ON\"}}}");
  MQTTPublish(light_set_topic, publishPayload);

}

void MQTTPublish(const char *topic, char *payload)
{
  mqtt.publish(topic, payload);
  Serial.print("Published [");
  Serial.print(topic);
  Serial.print("] ");
  Serial.println(payload);
}

void loop() {

  if(!ethClient.connected()){
    ethClient.stop();
    setup_ethernet();
  }
  
  if (!mqtt.connected()) {
    reconnect();
  }else{
    mqtt.loop(); 
  }
}

2.- Run the code.

Expected behavior
Connect Successfully

Screenshots/Serial Output

IP address:
192.168.100.133
Attempting MQTT connection...(SSLClient)(SSL_ERROR)(connect): Failed to connect using m_client. Are you connected to the internet?
failed, rc=-2 try again in 5 seconds
Ready

IP address:
192.168.100.133
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_CONNECT_FAIL
Attempting MQTT connection...(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_CONNECT_FAIL
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_CONNECT_FAIL
(SSLClient)(SSL_ERROR)(connect): Failed to connect using m_client. Are you connected to the internet?
failed, rc=-2 try again in 5 seconds

Context (please complete the following information):
Arduino Due
EthernetShield
EthernetLarge
SSLClient
PubSubClient

Convert cert to Trust Anchor - empty certificates.h

I'm attempting to use the pycert_bearssl.py script to convert the .crt file (PEM format) from https://test.mosquitto.org/

I followed the instructions at https://github.com/OPEnSLab-OSU/SSLClient/blob/master/TrustAnchors.md and I am able to run the script, but the output of certificates.h is empty.

I used the command:
py pycert_bearssl.py convert --no-search

As I said before, the script runs without issue, but the output file is empty.

I'm hoping it's something simple I've missed.

Thanks,
Gregor

HandShake Certificate

hello friend
how can I use this function so that it recevies Auto handshake without certificate???
exp : when using class esp8266secure can get data handshake & its dosent need cert.h class or function & gets the certificate automaticaly the same as chrome browser when searching the web site
thx

What a treasure I have discovered here, is speak-less.

Describe the bug
I did not find appropriate label to mark this post. May God bless the creator of this library.
Wow, wow wow!!!!!! I'm happy for accidental discover of this repository.

To Reproduce
Write some steps to reproduce the behavior. Be sure to include the vant hardware required, if any.

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
It is already just FINE!

Screenshots/Serial Output
If applicable, add screenshots or serial logs to help explain your problem.

Context (please complete the following information):

  • ESP32
  • Arduino Core Version 1.8.13

Additional context
Add any other context about the problem here.

Works perfectly with ArduinoMqttClient on Arduino Due, same code gives inconsistent SSL errors on Teensy 4.1

I have a program that is an MQTT client for AWS IoT service, which means it uses mTLS and certificate authentication. The same codebase has been tested on:

  1. Seeeduino XIAO (SAMD21)
  2. Arduino Due (SAM3X8E)

I had repeated and continual success connecting to AWS IoT MQTT using AWS-issued certificates, as well as a private TLS-only Mosquitto server using self-signed certificates (so yes, I'm familiar with using SSLClientParameters::fromPEM() and sslClient.setMutualAuthParams(), as well as creating a certificates.h file from root certificates).

I've been trying to use the same code on a new Teensy 4.1 (ARM Cortex M7), but I seem to have trouble with SSLClient. The errors I get are different almost every time (each one of these was from a single connection attempt from a fresh boot):

  1. (SSLClient)(SSL_ERROR)(m_update_engine): Error writing to m_client
    (SSLClient)(SSL_ERROR)(m_update_engine): 0
    (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
    (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
    (SSLClient)(SSL_WARN)(m_run_until): Terminating with write error:
    (SSLClient)(SSL_WARN)(m_run_until): 4
    (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
    (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0

  2. (SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
    (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
    (SSLClient)(SSL_ERROR)(m_print_br_error): Unsupported or invalid algorithm (ECDHE curve, signature algorithm, hash function).

  3. (SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
    (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
    (SSLClient)(SSL_ERROR)(m_print_br_error): Issuer/Subject DN mismatch in the chain.

  4. (SSLClient)(SSL_ERROR)(m_run_until): SSL internals timed out! This could be an internal error, bad data sent from the server, or data being discarded due to a buffer overflow. If you are using Ethernet, did you modify the library properly (see README)?
    (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
    (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
    (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
    (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0

There have been others, but these were the four that I captured when I made the decision to file a bug.

Troubleshooting:
One of the troubleshooting steps was to completely remove SSLClient and test MQTT connections to a test server without encryption, which worked, so it's not the network hardware nor anything else I'm doing in code.

I have scoured the SSLClient source to see if there were any flags that were different between the Due and Teensy platforms that might be throwing things off during compile, but I didn't notice anything interesting.

Context:

  • Teensy 4.1 (600MHz ARM Cortex M7, 1024K RAM)
  • Teensyduino v1.53 (based on Arduino Core 1.8.13)
  • Relevant Libraries:
    • TinyGSM v0.10.9
    • ArduinoMqttClient v0.1.5 (have also tested with PubSubClient v2.8)
  • SSLClient Version 1.6.10

Additional context
The same codebase has been used on other devices not listed above, but those were not using this library. I only mention this to further assert that everything else in my MQTT client program works fine.

Network access is provided by cellular modem. The Arduino Due used a SIM7000A, and the Teensy 4.1 is using a u-blox SARA-R410M.

I ran the TinyGSM HttpsClient demo, which successfully downloaded the TinyGSM text logo over HTTPS. Of course, this has nothing to do with SSLClient, I'm only making the point that encrypted communication is possible on this setup.

I haven't included any code snippets in this initial report because I'm not sure it's relevant yet. My main goal here is to see if any other Teensy 4.x users might be having the same experience, or to see if anyone smarter than me might know of things to check or tweak.

ESP32 W5500 MQTT SSL

Hello,
I can easily connect to my MQTT server from my pc with the ca.cert file and on the port 8883. But the ESP32 says:

My IP address: 192.168.170.151.
Connecting to MQTT...
(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Expected server name was not found in the chain.
failed with state -2Connecting to MQTT...
(SSLClient)(SSL_ERROR)(connect): Cannot have two connections at the same time! Please create another SSLClient instance.
failed with state -2Connecting to MQTT...
(SSLClient)(SSL_ERROR)(connect): Cannot have two connections at the same time! Please create another SSLClient instance.
failed with state -2Connecting to MQTT...

The Server shows me an new connection with the IP 192.168.170.151 without any reaction.

My actually code:

#include <SPI.h>
#include <Ethernet2.h>
#include <SSLClient.h>
#include "certificates.h" // This file must be regenerated
#include <PubSubClient.h>


const char my_cert[] = 
"-----BEGIN CERTIFICATE-----\n" 
................
"-----END CERTIFICATE-----";

const char my_key[] = 
"-----BEGIN RSA PRIVATE KEY-----\n"
...............
"-----END RSA PRIVATE KEY-----\n";

SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key);

byte mac[] = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xEF };
const char* mqttServer = "192.168.170.143";
const int mqttPort = 8883;

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

EthernetClient ethClient;
SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, A5);
PubSubClient client(ethClientSSL);

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.println("Connecting to MQTT...");

    if (client.connect("ESP32") {

      Serial.println("connected");
      client.subscribe("#");
    } else {

      Serial.print("failed with state ");
      Serial.print(client.state());
      delay(2000);

    }
  }
}

void setup(){
  Serial.begin(115200);
  while(!Serial);

  ethClientSSL.setMutualAuthParams(mTLS);
  Ethernet.init(27);  // Most Arduino shields
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
      ;
  }
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.println();

  client.setServer(mqttServer, mqttPort);
  client.setCallback(callback);
 
  while (!client.connected()) {
    Serial.println("Connecting to MQTT...");
 
    if (client.connect("ESP32_Garage") {
 
      Serial.println("connected");   
    } else {
 
      Serial.print("failed with state ");
      Serial.print(client.state());
      delay(2000);
 
    }
  }
}

void loop(){
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
}

SSLClient terminating when flushing buffer

I am trying to connect my ESP32 to my MQTT Broker (mosquitto on RaspberryPi) via WiFi.
My code is based on the EthernetMQTT example, but i exchanged the ethernet client for WiFi.

The esp32 succesfully connects to the Broker and publishes a first message, but afte that I get the errormessage:

(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
(SSLClient)(SSL_ERROR)(flush): Could not flush write buffer!

It seems that using the flush() function is crashing the sslClient, wich is unfortunate, because as described in #9, not using the flush() function after every write to the network results in an a stack overflow.

How do I go about this error? Is it possible to get a kind of stable connection?

My full code:

/**
   A BLE client example that is rich in capabilities.
   There is a lot new capabilities implemented.
   author unknown
   updated by chegewara
*/

#include <WiFi.h>
#include <PubSubClient.h>
//SSL
#include <SSLClient.h>
#include "certificates.h" // This file must be regenerated

const char my_cert[] = "FIXME";
const char my_key[] = "FIXME";
SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key);

// Setup Wifi
const char* ssid = "...";
const char* password = "...";

const char* mqtt_server = "192.168.2.105";

WiFiClient espClient;
SSLClient espClientSSL(espClient, TAs, (size_t)TAs_NUM, A5);
PubSubClient client(espClientSSL);

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP32Client")) {
      Serial.println("connected");

      // Once connected, publish an announcement...
      client.publish("outTopic", "hello world");
      // This is a workaround to address https://github.com/OPEnSLab-OSU/SSLClient/issues
      Serial.print("calling flush() \n");
      espClientSSL.flush();
      Serial.print("flush() finished \n");

      // Subscribe
      //client.subscribe("testtopic/Win");
      // This is a workaround to address https://github.com/OPEnSLab-OSU/SSLClient/issues
      //espClientSSL.flush();

    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

void setup() {
  Serial.begin(115200);
  while (!Serial);

  // Enable mutual TLS with SSLClient
  espClientSSL.setMutualAuthParams(mTLS);

  //Connecting to Wifi and MQTT Broker
  setup_wifi();
  client.setServer(mqtt_server, 8883);
  client.setCallback(callback);
}

void loop() {

  //MQTT
  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  //Serial.print("Attempting MQTT hello there!");

  client.publish("testtopic/ESP", "hello there!");
  // This is a workaround to address https://github.com/OPEnSLab-OSU/SSLClient/issues
  espClientSSL.flush();

  delay(3000); // Delay a second between loops.
} // End of loop

longer serial output:

...
WiFi connected
Attempting MQTT connection...connected
calling flush() 
(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
(SSLClient)(SSL_ERROR)(flush): Could not flush write buffer!
flush() finished 
Attempting MQTT connection...connected
calling flush() 

Serverside log:

1609262639: New connection from 192.168.2.73 on port 8883.
1609262639: New client connected from 192.168.2.73 as ESP32Client (p2, c1, k15).
1609262661: Client ESP32Client has exceeded timeout, disconnecting.
1609262662: New connection from 192.168.2.73 on port 8883.
1609262662: New client connected from 192.168.2.73 as ESP32Client (p2, c1, k15).

It seems the issue at https://github.com/OPEnSLab-OSU/SSLClient/issues/27 need a resuscitation

Describe the bug
setVerificationTime gives compilation error.

Screenshots/Serial Output
error: 'setVerificationTime' was not declared in this scope

Context (please complete the following information):

  • Al-thinker ESP32-CAM
  • Arduino Core Version 1.8.13

Additional context
I have used the algorithm introduced here; https://www.geeksforgeeks.org/find-number-of-days-between-two-given-dates/ and successfully passed the performance. As arguments were used the result of code, introduced here https://github.com/vshymanskyy/TinyGSM/blob/master/examples/AllFunctions/AllFunctions.ino given at 335-352 lines
Trying to put the difference between 1.1.1 and today days and elapsed seconds for the moment into "setVerificationTime" return compile error. What I do not do as required?
For more details, i should report that the whole code without given task doing well and interacts with telegram bot via GSM connection. Simply, I would like to eliminate possible certificate expiration in the future.

support for TLS PSK

I have to implement a client for MQTTS with mosquitto as broker with TLS PSK.
I cannot understand if this library support TLS PSK (Pre-Shared Key) and how implement it .

Many thanks in advance for any suggestion

Paolo

ESP32 MQTT Communication with AWS works only one-way

Hello,
TL,DR: ESP32 with W5100 ethernet shield communication only works one way (sending, not receiving). might be due to the way the credentials are loaded?

I'm trying to migrate a code running on ESP32 that used to work with Wifi & WiFiClientSecure and has used the Arduino MQTT library - https://github.com/256dpi/arduino-mqtt.
The code has worked alright aside to disconnection issues of the WiFi that might be related to the physical site and thus we decided to test migration to an ethernet solution.
I plugged a W5100 ethernet shield, tested it successfully with the WebClient example and began migrating the whole product code to the ethernet solution based on EthernetAWSIoT.ino example.

The example works ok, however, I do not store the certificate and key as part of the code but read them to the memory using SPIFFS. this way I can keep them on the device and issue an update OTA with the credentials stored safely inside.

The problem I have is that this appears to be working only one way, that is the update of the MQTT topic goes as planned, but the subscribing or processing of the messages on a different topic simply does not happen.

I have also tested it to happen on the EthernetAWSIoT.ino example below.
I have also tried replacing the MQTT client to be 256dpi/arduino-mqtt instead of PubSubClient and that didn't work at all.
Any ideas where should I check for the lost data?

#include <Arduino.h>
#include <SPI.h>
#include <EthernetLarge.h>
#include <SSLClient.h>
#include <PubSubClient.h>
#include "AWS_Root_CA.h"

//CERTS SPIFFS:
#include "secrets.h"
#include "FS.h"
#include "SPIFFS.h"

#define THING_NAME "******"
#define MQTT_PACKET_SIZE 1024
#define MQTT_KEEP_ALIVE 10
#define MQTT_TIMEOUT 5000

const char* mqttServer = "********.iot.us-east-1.amazonaws.com";
char publishPayload[MQTT_PACKET_SIZE];
char *subscribeTopic = "****/sub/" THING_NAME "";
char *publishTopic = "****/pub/" THING_NAME "";
void callback(char* topic, byte* payload, unsigned int length) 
{
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) 
  {
    Serial.print((char)payload[i]);
  }
  Serial.println();
  updateThing();
}

EthernetClient ethClient;
SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, 36);//, 1, SSLClient::SSL_INFO); // A0
PubSubClient mqtt_client(mqttServer, 8883, callback, ethClientSSL);

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

void reconnect() 
{
  while (!mqtt_client.connected()) 
  {
    Serial.print("Attempting MQTT connection...");
    if (mqtt_client.connect("arduinoClient")) 
    {
      Serial.println("connected");
    //   for (int i = 0; i < 2; i++) 
    //   {
    //    Serial.println(subscribeTopic[i]);
        // mqtt.subscribe(subscribeTopic[i]);
    //   }
        Serial.println(subscribeTopic);
        mqtt_client.subscribe(subscribeTopic);
        // ethClientSSL.flush();
        Serial.println("Started updateThing ");
        updateThing();
        Serial.println("Done updateThing ");

    } 
    else 
    {
      Serial.print("failed, rc=");
      Serial.print(mqtt_client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);
    }
  }
}

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  Ethernet.init(5);  // Most Arduino shields

  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//CERTS SPIFFS:
  if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
        Serial.println("SPIFFS Mount Failed");
        return;
    }
  // find certificate and thing files based on search strings
  findSigFiles(SPIFFS, "/", 0);

  // print file contents if available
  readFile(SPIFFS, AWS_CERT_CRT_FILEPATH);
  readFile(SPIFFS, AWS_CERT_PRIVATE_FILEPATH);

  // load file certs into arrays
  loadFile(AWS_CERT_CRT_FILEPATH, AWS_CERT_CRT_LOADED);
  loadFile(AWS_CERT_PRIVATE_FILEPATH, AWS_CERT_PRIVATE_LOADED);

  SPIFFS.end();

//end CERTS SPIFFS
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());

   SSLClientParameters mTLS = SSLClientParameters::fromPEM(AWS_CERT_CRT_LOADED, 1220, AWS_CERT_PRIVATE_LOADED, 1679);
 ethClientSSL.setMutualAuthParams(mTLS);
  mqtt_client.setBufferSize(MQTT_PACKET_SIZE);
  mqtt_client.setKeepAlive(MQTT_KEEP_ALIVE);
  mqtt_client.setSocketTimeout(MQTT_TIMEOUT/1000);
}

void loop() {
  if (!mqtt_client.connected()) 
  {
    reconnect();
  }
  mqtt_client.loop();
}


void updateThing()
{
  strcpy(publishPayload, "{\"state\": {\"reported\": {\"powerState\":\"ON\"}}}");
//   MQTTPublish(publishShadowUpdate, publishPayload);
MQTTPublish(publishTopic, publishPayload);

}

void MQTTPublish(const char *topic, char *payload)
{
  mqtt_client.publish(topic, payload);
  Serial.print("Published [");
  Serial.print(topic);
  Serial.print("] ");
  Serial.println(payload);
}

Thanks!

make m_iobuf adjustable

Is your feature request related to a problem? Please describe.
That would be great to make m_iobuf adjustable without changing the library code.

Describe the solution you'd like
It can be done by defining a buffer size using #define or via making m_iobuf declared in dynamic way. Which way is better?

Two SSL simultaneous connections trouble

Is your question related to a problem? Please describe.
The project has been realized on LilyGo-T-Call-SIM800L, Everything was fine with SSL connection with my own domain based MQTT broker having used the TinyGSM library. Then I have decided to use also a Telegram bot and get notifications on own channel on-demand. It's "Universal Telegram Bot Library" used. Upon GPRS successful connection an Telegram alert comes, again successfully. Since then MQTT publishing is too successful, but when the publishing on MQTT and on Telegram have significant shift in time domain. Adjacent commands of MQTT then Telegram messages publishing or vice versa, crushes the SSL connection with broker. Some milliseconds delay adding in between two publishing does not fix the problem.
Terminal view log:
01:21:26.084 -> Message arrived on topic: esp/whatsapp. Message: true 01:21:29.720 -> (SSLClient)(SSL_ERROR)(available): SSL engine failed to update. 01:21:29.720 -> (SSLClient)(SSL_ERROR)(available): Cannot operate on a closed SSL connection.
The code portion which makes the crush:
else if (String(topic) == "esp/whatsapp") { if (messageTemp == "true") { whatsappflag = !whatsappflag; if (whatsappflag) { mqtt.publish(topicWhatsappStatus, "green"); if (startflag) mqtt.publish(topicEnginestatus, "green"); else mqtt.publish(topicEnginestatus, "red"); if (armstatusflag) mqtt.publish(topicarm, "green"); else { mqtt.publish(topicarm, "red"); } bot.sendMessage(CHAT_ID, "Whatsapp flag set!!", ""); SerialMon.println("Whatsapp flag set"); } else mqtt.publish(topicWhatsappStatus, "red"); SerialMon.println("Changing Whatsapp to " + (String(whatsappflag))); } }

Hangs on `br_ssl_engine_recvrec_ack()` call

Describe the bug
I tried to use SSLClient on Arduino MKR NB 1500 with NB-IoT radio.
When I try to establish an HTTPS connection to google.com, it is getting stuck.
I have traced it down to br_ssl_engine_recvrec_ack() call, but I don't know how to add debug prints to BearSSL itself.

To Reproduce
I'm using Arduino MKR NB 1500 with PlatformIO.

  1. Checkout project at https://github.com/buoys-dev/buoy/tree/experiment/sslclient , experiment/sslclient branch.
  2. Open PlatformIO IDE, upload firmware to device.
  3. Monitor serial port.

Expected behavior
Google's robots.txt displayed in the serial port.

Context (please complete the following information):

  • Arduino MKR NB 1500
  • PlatformIO
  • SSLClient latest from master branch - 1fe48948004a3ad52705ab26db4f65833ecb4e12

Screenshots/Serial Output
Serial log:

Click to expand!
Starting Arduino web client.
AT
OK
AT
OK
AT
OK
AT+CMEE=0
OK

+PACSP0
AT+CFUN=0
OK
AT+CPIN?
+CPIN: READY

OK
AT+CMGF=1
OK
AT+UDCONF=1,1
OK
AT+CTZU=1
OK
AT+CGDCONT=1,"IP",""
OK
AT+UAUTHREQ=1,0
OK
AT+CFUN=1
OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,1

OK
AT+CGATT=1
OK
AT+CGACT?
+CGACT: 1,1

OK
connecting to google.com...
AT+USOCR=6
+USOCR: 0

OK
AT+USOCO=0,"google.com",443
OK
(SSLClient)(SSL_INFO)(connect): Base client connected!
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDREC
AT+USOWR=0,131,"160303007E0100007A0303000000006B9D67954CEAE649C5FF1E7C42AF211268EE80EA87A2FE7980238EEF00000CCCA9CCA8C02BC02FC02DC03101000045FF010001000000000F000D00000A676F6F676C652E636F6D0001000103000D0012001004030303050306030401030105010601000A00080006001700180019000B00020100"
+USOWR: 0,131

OK
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 5
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered

+UUSORD: 0,1380
AT+USORD=0,512

+USORD: 0,512,"1603030057020000530303610B3E42D024CD053464F247F1EBC3301551BBF8D33AC3CB444F574E4752440120683B26612869E2EF642170F7697C1BFB97472822C6234CBEFD0BB1840F88D770CCA900000BFF01000100000B0002010016030318640B00186000185D000D5430820D5030820C38A0030201020210244E52D96B551F960A00000000F2BAF4300D06092A864886F70D01010B05003046310B300906035504061302555331223020060355040A1319476F6F676C65205472757374205365727669636573204C4C43311330110603550403130A47545320434120314333301E170D3231303731323031333533315A170D3231313030343031333533305A30173115301306035504030C0C2A2E676F6F676C652E636F6D3059301306072A8648CE3D020106082A8648CE3D030107034200044831D7E28BD63DF68858F3593C2289193C7B423139D2089F593532C3EB7B0E436FABEDA712BAE95A871D89F6033A85FC13EEB725D10596B47086EE235D985E60A3820B3230820B2E300E0603551D0F0101FF04040302078030130603551D25040C300A06082B06010505070301300C0603551D130101FF04023000301D0603551D0E04160414DE6E24C4AE68ED9387F12F4FB79B5D25FA330DD0301F0603551D230418301680148A747FAF85CDEE95CD3D9CD0E24614F371351D27306A06082B06010505070101045E305C"
OK

+UUSORD: 0,868
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512

+USORD: 0,512,"302706082B06010505073001861B687474703A2F2F6F6373702E706B692E676F6F672F677473316333303106082B060105050730028625687474703A2F2F706B692E676F6F672F7265706F2F63657274732F6774733163332E646572308208E20603551D11048208D9308208D5820C2A2E676F6F676C652E636F6D82162A2E617070656E67696E652E676F6F676C652E636F6D82092A2E62646E2E64657682122A2E636C6F75642E676F6F676C652E636F6D82182A2E63726F7764736F757263652E676F6F676C652E636F6D82182A2E64617461636F6D707574652E676F6F676C652E636F6D820B2A2E676F6F676C652E6361820B2A2E676F6F676C652E636C820E2A2E676F6F676C652E636F2E696E820E2A2E676F6F676C652E636F2E6A70820E2A2E676F6F676C652E636F2E756B820F2A2E676F6F676C652E636F6D2E6172820F2A2E676F6F676C652E636F6D2E6175820F2A2E676F6F676C652E636F6D2E6272820F2A2E676F6F676C652E636F6D2E636F820F2A2E676F6F676C652E636F6D2E6D78820F2A2E676F6F676C652E636F6D2E7472820F2A2E676F6F676C652E636F6D2E766E820B2A2E676F6F676C652E6465820B2A2E676F6F676C652E6573820B2A2E676F6F676C652E6672820B2A2E676F6F676C652E6875820B2A2E676F6F676C652E6974820B2A2E676F6F676C652E6E6C820B2A2E676F6F676C652E"
OK

+UUSORD: 0,356
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512

+USORD: 0,356,"706C820B2A2E676F6F676C652E707482122A2E676F6F676C656164617069732E636F6D820F2A2E676F6F676C65617069732E636E82112A2E676F6F676C65766964656F2E636F6D820C2A2E677374617469632E636E82102A2E677374617469632D636E2E636F6D82122A2E67737461746963636E617070732E636E820F676F6F676C65636E617070732E636E82112A2E676F6F676C65636E617070732E636E820C676B65636E617070732E636E820E2A2E676B65636E617070732E636E8212676F6F676C65646F776E6C6F6164732E636E82142A2E676F6F676C65646F776E6C6F6164732E636E82107265636170746368612E6E65742E636E82122A2E7265636170746368612E6E65742E636E820B7769646576696E652E636E820D2A2E7769646576696E652E636E8211616D7070726F6A6563742E6F72672E636E82132A2E616D7070726F6A6563742E6F72672E636E8211616D7070726F6A6563742E6E65742E636E"
OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 4091
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered

+UUSORD: 0,1380
AT+USORD=0,512

+USORD: 0,512,"82132A2E616D7070726F6A6563742E6E65742E636E8217676F6F676C652D616E616C79746963732D636E2E636F6D82192A2E676F6F676C652D616E616C79746963732D636E2E636F6D8217676F6F676C65616473657276696365732D636E2E636F6D82192A2E676F6F676C65616473657276696365732D636E2E636F6D8211676F6F676C65766164732D636E2E636F6D82132A2E676F6F676C65766164732D636E2E636F6D8211676F6F676C65617069732D636E2E636F6D82132A2E676F6F676C65617069732D636E2E636F6D8215676F6F676C656F7074696D697A652D636E2E636F6D82172A2E676F6F676C656F7074696D697A652D636E2E636F6D8212646F75626C65636C69636B2D636E2E6E657482142A2E646F75626C65636C69636B2D636E2E6E657482182A2E666C732E646F75626C65636C69636B2D636E2E6E657482162A2E672E646F75626C65636C69636B2D636E2E6E65748211646172747365617263682D636E2E6E657482132A2E646172747365617263682D636E2E6E6574821D676F6F676C6574726176656C616473657276696365732D636E2E636F6D821F2A2E676F6F676C6574726176656C616473657276696365732D636E2E636F6D8218676F6F676C6574616773657276696365732D636E2E636F6D821A2A2E676F6F676C6574616773657276696365732D636E2E636F6D8217676F6F676C6574"
OK

+UUSORD: 0,868
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512

+USORD: 0,512,"61676D616E616765722D636E2E636F6D82192A2E676F6F676C657461676D616E616765722D636E2E636F6D8218676F6F676C6573796E6469636174696F6E2D636E2E636F6D821A2A2E676F6F676C6573796E6469636174696F6E2D636E2E636F6D82242A2E736166656672616D652E676F6F676C6573796E6469636174696F6E2D636E2E636F6D82166170702D6D6561737572656D656E742D636E2E636F6D82182A2E6170702D6D6561737572656D656E742D636E2E636F6D820B677674312D636E2E636F6D820D2A2E677674312D636E2E636F6D820B677674322D636E2E636F6D820D2A2E677674322D636E2E636F6D820B326D646E2D636E2E6E6574820D2A2E326D646E2D636E2E6E65748214676F6F676C65666C69676874732D636E2E6E657482162A2E676F6F676C65666C69676874732D636E2E6E6574820C61646D6F622D636E2E636F6D820E2A2E61646D6F622D636E2E636F6D820D2A2E677374617469632E636F6D82142A2E6D65747269632E677374617469632E636F6D820A2A2E677674312E636F6D82112A2E67637063646E2E677674312E636F6D820A2A2E677674322E636F6D820E2A2E6763702E677674322E636F6D82102A2E75726C2E676F6F676C652E636F6D82162A2E796F75747562652D6E6F636F6F6B69652E636F6D820B2A2E7974696D672E636F6D820B616E64726F69642E636F6D820D2A"
OK

+UUSORD: 0,356
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512

+USORD: 0,356,"2E616E64726F69642E636F6D82132A2E666C6173682E616E64726F69642E636F6D8204672E636E82062A2E672E636E8204672E636F82062A2E672E636F8206676F6F2E676C820A7777772E676F6F2E676C8214676F6F676C652D616E616C79746963732E636F6D82162A2E676F6F676C652D616E616C79746963732E636F6D820A676F6F676C652E636F6D8212676F6F676C65636F6D6D657263652E636F6D82142A2E676F6F676C65636F6D6D657263652E636F6D820867677068742E636E820A2A2E67677068742E636E820A75726368696E2E636F6D820C2A2E75726368696E2E636F6D8208796F7574752E6265820B796F75747562652E636F6D820D2A2E796F75747562652E636F6D8214796F7574756265656475636174696F6E2E636F6D82162A2E796F7574756265656475636174696F6E2E636F6D820F796F75747562656B6964732E636F6D82112A2E796F75747562656B6964732E636F6D820579742E6265"
OK
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512
+USORD: 0,""

OK
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 3581
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered

+UUSORD: 0,1380
AT+USORD=0,512

+USORD: 0,512,"82072A2E79742E6265821A616E64726F69642E636C69656E74732E676F6F676C652E636F6D821B646576656C6F7065722E616E64726F69642E676F6F676C652E636E821C646576656C6F706572732E616E64726F69642E676F6F676C652E636E8218736F757263652E616E64726F69642E676F6F676C652E636E30210603551D20041A30183008060667810C010201300C060A2B06010401D679020503303C0603551D1F043530333031A02FA02D862B687474703A2F2F63726C732E706B692E676F6F672F6774733163332F517146786269394D3438632E63726C30820104060A2B06010401D6790204020481F50481F200F0007600EEC095EE8D72640F92E3C3B91BC712A3696A097B4B6A1A1438E647B2CBEDC5F90000017A9891D65D0000040300473045022100FF9843A5B759051498AFE16BBB14E6BE632BCBF72CDB8B93FC826AB81F009DAC022044D5D97205F87005F779883E821D7978A746F8C3AF22ED755B71BA9A397C29C90076007D3EF2F88FFF88556824C2C0CA9E5289792BC50E78097F2E6A9768997E22F0D70000017A9891D6860000040300473045022100A9F356998C8006ABA3DBDD6BC3A8F28445EF7F2958304637411F1513A8E3C9830220367E524513775637D19937A3C69492E1DDBA976F8C78861F95B75F348338C991300D06092A864886F70D01010B05000382010100C10B9E6B58EA5F31C8"
OK

+UUSORD: 0,868
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() br_ssl_engine_recvrec_ack() returned.
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() BR_SSL_RECVREC section entered
AT+USORD=0,512

+USORD: 0,512,"251A49B6FCDDA646738414B12173BCBB5AA418ECA41A15B175D155431C45804C696F0F44D017A054885909EA8F9828BDE505C7586938864C7F53CC24225B5312F635607C2A6E66C2F55CF10C48BB6BD21240DDCF62FB9AA771C662B2877B13217774BBF04E2016288783B29E2B115301A775B2F61241193E989DF82F105DBD88EC00AA83F687E026CA6BCEA141A0BE21B4D1265CB536571C699A422BEF7591C7C04FEC0CAC0DE7C4ECEBE6B8065CAB396CF1EAEFA4E85F25D7278ADF1E62CA268A18AA38D472324AFD15F50561B8C541C16884D6B87EBD93B5F30AF32D1C81004F0369803F56676FFE5044401A641FDE4B8AA732BDE46900059A308205963082037EA003020102020D0203BC53596B34C718F5015066300D06092A864886F70D01010B05003047310B300906035504061302555331223020060355040A1319476F6F676C65205472757374205365727669636573204C4C43311430120603550403130B47545320526F6F74205231301E170D3230303831333030303034325A170D3237303933303030303034325A3046310B300906035504061302555331223020060355040A1319476F6F676C65205472757374205365727669636573204C4C43311330110603550403130A4754532043412031433330820122300D06092A864886F70D01010105000382010F003082010A0282010100F588DFE7628C1E37F8"
OK

+UUSORD: 0,356
(SSLClient)(SSL_INFO)(m_update_engine): m_update_engine() rlen > 0 section entered. Calling br_ssl_engine_recvrec_ack().

How to use same sslclient for mqtt and ota?

I have an mqtt connection working with SSLClient. I want to do an OTA update using the same client. I added certs for MQTT and for OTA. and when i receive the OTA message I want my device to perform ota with link received in message.
function that handles ota looks like this:


// performs ota update with link to ota
bool start_ota(String link, SSLClient *otaClient)
{
    Log.notice("trying OTA with link %s\n", link.c_str());
    int port = 443;

    bool result = true;
    link.replace("https://", "");
    uint8_t idx = link.indexOf("/");
    String host = link.substring(0, idx);
    String bin = link.substring(0, idx);

    Serial.println("Connecting to: " + String(host));
    // Connect to S3
    if (otaClient->connect(host.c_str(), port))
    {
        // Connection Succeed.
        // Fecthing the bin
        Serial.println("Fetching Bin: " + String(bin));

        // Get the contents of the bin file
        otaClient->print(String("GET ") + bin + " HTTP/1.1\r\n" +
                        "Host: " + host + "\r\n" +
                        "Cache-Control: no-cache\r\n" +
                        "Connection: close\r\n\r\n");

        // Check what is being sent
        //    Serial.print(String("GET ") + bin + " HTTP/1.1\r\n" +
        //                 "Host: " + host + "\r\n" +
        //                 "Cache-Control: no-cache\r\n" +
        //                 "Connection: close\r\n\r\n");

        unsigned long timeout = millis();
        while (otaClient->available() == 0)
        {
            if (millis() - timeout > 5000)
            {
                Serial.println("Client Timeout !");
                otaClient->stop();
                result = false;
            }
        }
        // Once the response is available,
        // check stuff

        /*
       Response Structure
        HTTP/1.1 200 OK
        x-amz-id-2: NVKxnU1aIQMmpGKhSwpCBh8y2JPbak18QLIfE+OiUDOos+7UftZKjtCFqrwsGOZRN5Zee0jpTd0=
        x-amz-request-id: 2D56B47560B764EC
        Date: Wed, 14 Jun 2017 03:33:59 GMT
        Last-Modified: Fri, 02 Jun 2017 14:50:11 GMT
        ETag: "d2afebbaaebc38cd669ce36727152af9"
        Accept-Ranges: bytes
        Content-Type: application/octet-stream
        Content-Length: 357280
        Server: AmazonS3
                                   
        {{BIN FILE CONTENTS}}
    */
        while (otaClient->available())
        {
            // read line till /n
            String line = otaClient->readStringUntil('\n');
            // remove space, to check if the line is end of headers
            line.trim();

            // if the the line is empty,
            // this is end of headers
            // break the while and feed the
            // remaining `client` to the
            // Update.writeStream();
            if (!line.length())
            {
                //headers ended
                break; // and get the OTA started
            }

            // Check if the HTTP Response is 200
            // else break and Exit Update
            if (line.startsWith("HTTP/1.1"))
            {
                if (line.indexOf("200") < 0)
                {
                    Serial.println("Got a non 200 status code from server. Exiting OTA Update.");
                    break;
                }
            }

            // extract headers here
            // Start with content length
            if (line.startsWith("Content-Length: "))
            {
                contentLength = atol((getHeaderValue(line, "Content-Length: ")).c_str());
                Serial.println("Got " + String(contentLength) + " bytes from server");
            }

            // Next, the content type
            if (line.startsWith("Content-Type: "))
            {
                String contentType = getHeaderValue(line, "Content-Type: ");
                Serial.println("Got " + contentType + " payload.");
                if (contentType == "application/octet-stream")
                {
                    isValidContentType = true;
                }
            }
        }
    }
    else
    {
        // Connect to S3 failed
        // May be try?
        // Probably a choppy network?
        Serial.println("Connection to " + String(host) + " failed. Please check your setup");
        // retry??
        // execOTA();
    }

    // Check what is the contentLength and if content type is `application/octet-stream`
    Serial.println("contentLength : " + String(contentLength) + ", isValidContentType : " + String(isValidContentType));

    // check contentLength and content type
    if (contentLength && isValidContentType)
    {
        // Check if there is enough to OTA Update
        bool canBegin = Update.begin(contentLength);

        // If yes, begin
        if (canBegin)
        {
            Serial.println("Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!");
            // No activity would appear on the Serial monitor
            // So be patient. This may take 2 - 5mins to complete
            size_t written = Update.writeStream(*otaClient);

            if (written == contentLength)
            {
                Serial.println("Written : " + String(written) + " successfully");
            }
            else
            {
                Serial.println("Written only : " + String(written) + "/" + String(contentLength) + ". Retry?");
                result = false;
            }

            if (Update.end())
            {
                Serial.println("OTA done!");
                if (Update.isFinished())
                {
                    Serial.println("Update successfully completed. Rebooting.");
                }
                else
                {
                    Serial.println("Update not finished? Something went wrong!");
                    result = false;
                }
            }
            else
            {
                Serial.println("Error Occurred. Error #: " + String(Update.getError()));
                result = false;
            }
        }
        else
        {
            // not enough space to begin OTA
            // Understand the partitions and
            // space availability
            Serial.println("Not enough space to begin OTA");
            otaClient->flush();
            result = false;
        }
    }
    else
    {
        Serial.println("There was no content in the response");
        otaClient->flush();
        result = false;
    }
    return result;
}

before starting ota I disconnect from mqtt with next code:

// startin ota
    mqttClient->disconnect();
    if (!start_ota(payload.c_str(), &netClient))
    {
     // log something
    }
    ESP.restart();

Here is the logs of mqtt disconnect and OTA routines:

(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVAPP
incoming: /commands/ota
N: need to perform ota
�(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
   SENDAPP
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDAPP
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDAPP
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDREC
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
   SENDAPP
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
   SENDAPP
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 5
(SSLClient)(SSL_ERROR)(m_run_until): SSL internals timed out! This could be an internal error, bad data sent from the server, or data being discarded due to a buffer overflow. If you are using Ethernet, did you modify the library properly (see README)?
[D][WiFiClient.cpp:509] connected(): Disconnected: RES: 0, ERR: 128
Socket was dropped unexpectedly (this can be an alternative to closing the connection)
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
(SSLClient)(SSL_ERROR)(flush): Could not flush write buffer!
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
N: trying OTA with link https://gofile.io/d/jSofs8dfs872
Connecting to: gofile.io
(SSLClient)(SSL_INFO)(connect): Base client connected!
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDREC
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 5
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   Connection closed
(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Server denied access (did you setup mTLS correctly?)

I think that not graceful mqtt disconnect causes this error. Is there any advice where to dig?

Getting error at converting the .pem

Hello there! I'm trying to create my certificates.h following the steps to get them. I have cloned the repo, and I have used the convert function like this:
python3 pycert_bearssl.py convert myca.pem

But it gives me the following errors:

File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue raise exception_type(errors) OpenSSL.crypto.Error: [('PEM routines', 'get_name', 'no start line')]

Anybody knows how to fix this?

Thank you so much for any support.

Basic HTTPS get on esp32 using WiFiClient not compiling (v1.0.2 ESP32 Core)

I just downloaded the library and tried to use it on my ESP32, using the Client WiFiClient but it won't compile because it says that SSLClient is abstract. I tried to look for this issue on internet but I couldn't find any forum talking about it. So here is my code (I'm using the Arduino IDE btw)

#include <WiFiClient.h>
#include <SSLClient.h>
#include "cert.h"

const char *ssid = "ssid";
const char *password = "pass";
const char *server = "api.wit.ai";
const char *endpoint = "/message?q=%C3%A9teins+la+lumi%C3%A8re";

const int port = 443;

WiFiClient baseClient;
const int rand_pin = 33;
SSLClient client(baseClient, TAs, (size_t)TAs_NUM, rand_pin);

void setup()
{
	WiFi.begin(ssid, password);

	Serial.println("Connection au WiFi");
	while (WiFi.status() != WL_CONNECTED)
	{
		delay(500);
		Serial.print(".");
	}
	Serial.print("Connecté au WiFi avec l'ip ");
	Serial.println(WiFi.localIp());

	if (client.connect(server, 443))
	{
		client.println(String("GET https://") + server + endpoint + " HTTP/1.1");
		client.println("User-Agent: SSLClientOverEthernet");
		client.print("Host: ");
		client.println(server_host);
		client.println("Authorization: credential);
		client.println("Connection: close");
		client.println();
	}
	else
	{
		Serial.println("connection failed");
	}
}

void loop()
{
	int len = client.available();
	if (len > 0)
	{
		byte buffer[80];
		if (len > 80)
			len = 80;
		client.read(buffer, len);
		if (printWebData)
		{
			Serial.write(buffer, len); // show in the serial monitor (slows some boards)
		}
		byteCount = byteCount + len;
	}
}

And here is the whole compiler error :

 SSLClient client(baseClient, TAs, (size_t)TAs_NUM, rand_pin);
           ^
In file included from C:\Users\Antonin\Documents\Arduino\google home maison\SSLClient_test\SSLClient_test.ino:2:0:
C:\Users\Antonin\Documents\Arduino\libraries\SSLClient-master\src/SSLClient.h:34:7: note:   because the following virtual functions are pure within 'SSLClient':
 class SSLClient : public Client {
       ^
In file included from C:\Users\Antonin\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.2\cores\esp32/Arduino.h:157:0,
                 from sketch\SSLClient_test.ino.cpp:1:
C:\Users\Antonin\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.2\cores\esp32/Client.h:31:17: note: 	virtual int Client::connect(IPAddress, uint16_t, int)
     virtual int connect(IPAddress ip, uint16_t port, int timeout) =0;
                 ^
C:\Users\Antonin\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.2\cores\esp32/Client.h:32:17: note: 	virtual int Client::connect(const char*, uint16_t, int)
     virtual int connect(const char *host, uint16_t port, int timeout) =0;
                 ^
C:\Users\Antonin\Documents\Arduino\google home maison\SSLClient_test\SSLClient_test.ino: In function 'void setup()':
SSLClient_test:18:2: error: 'WiFi' was not declared in this scope
  WiFi.begin(ssid, password);
  ^
SSLClient_test:21:26: error: 'WL_CONNECTED' was not declared in this scope
  while (WiFi.status() != WL_CONNECTED)
                          ^
SSLClient_test:34:18: error: 'server_host' was not declared in this scope
   client.println(server_host);
                  ^
C:\Users\Antonin\Documents\Arduino\google home maison\SSLClient_test\SSLClient_test.ino: In function 'void loop()':
SSLClient_test:54:7: error: 'printWebData' was not declared in this scope
   if (printWebData)
       ^
SSLClient_test:58:3: error: 'byteCount' was not declared in this scope
   byteCount = byteCount + len;
   ^
Plusieurs bibliothèque trouvées pour "WiFiClient.h"
Utilisé : C:\Users\Antonin\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.2\libraries\WiFi
Non utilisé : C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
cannot declare variable 'client' to be of abstract type 'SSLClient'

I hope there is enough information and that I can get help soon enough.
Thanks ^^

Dynamic Certificates

AWS IoT would like to see a certificate -per device-
It would be nice to be able to provision devices with their unique certificate on the fly.
Either by storing the certificate in EEPROM or on filesystem (I'm using LittleFS at this stage).

The SSLClientParameters::fromPEM() is used to provision the certificate information to the instance but at the moment of execution LittleFS is not approachable (this will become approachable once setup() starts; I'm using ArduinoIDE here)

Possible solution
Providing two reserved char arrays (key and cert) that will be filled once LittleFS has started in order to read out the certificates from the filesystem and put them in memory. I would like to provide a hard-coded "fallback" certificate and key which I could use to onboard devices.

Being able to call functions that change the certificate of the global instance would also be fine and probably even more flexible and generic.
I might be completely missing existing option due to lack of knowledge or general incompetence (one of my strong suits).
Having an example that shows how to deal with this would be great!

Is there a difference between this client and python ssl module | esp32 https chunked encoding

Hello, I want to use this client to stream audio to the wit.ai speech recognition api using HTTP chunked encoding.
I've been having problem since quite sometime now so in order to debug in a simpler way I've written a similar program in python.
So I used the socket and the ssl module of python assuming they'd be of the same level as this client. So here is my python code that I managed to make working :

import socket
import ssl
import time


def requestLog(ssock, string):
	print(string, end="")
	ssock.sendall(bytes(string, "ascii"))


hostname = 'api.wit.ai'
endpoint = "/speech"
context = ssl.create_default_context()
BIT_DEPTH = 8
RATE = 50000
f = open("./main/test.raw", "rb")#i'm reading a file to replicate the esp32 microphone (the data in the file come from the esp32
buffers = []
while True:
	buffer = f.read(RATE)
	if not len(buffer):  
		break
	else:
		buffers.append(buffer)


with socket.create_connection((hostname, 443)) as sock:
	with context.wrap_socket(sock, server_hostname=hostname) as ssock:
		requestLog(ssock,"POST " + endpoint + " HTTP/1.1\r\n")
		requestLog(ssock,"Host: " + hostname + "\r\n")
		requestLog(ssock,"Authorization: Bearer " + token + "\r\n")
		requestLog(ssock,f'Content-Type: audio/raw;encoding=signed-integer;bits={BIT_DEPTH};rate={RATE};endian=little\r\n')
		requestLog(ssock,"User-Agent: Mozilla/5.0\r\n")
		requestLog(ssock,"Transfer-Encoding: chunked\r\n")
		requestLog(ssock,"\r\n")

		for buffer in buffers:
			hexStr =hex(len(buffer))[2:]
			requestLog(ssock,hexStr)
			requestLog(ssock,"\r\n")
			ssock.sendall(buffer)
			print("<buffer content>")
			requestLog(ssock,"\r\n")


		requestLog(ssock,"0\r\n")
		requestLog(ssock,"\r\n")

So I wrote the "C++ version" of this code like this :

void startChunkedRequest(SSLClient client, String server, String endpoint)
{
  client.print(String("POST ") + endpoint + " HTTP/1.1\r\n");
  client.print(String("Host: ") + server + "\r\n");
  client.print("Authorization: Bearer " TOKEN "\r\n");
  client.print("Content-Type: audio/raw;encoding=signed-integer;bits=8;rate=50000;endian=little\r\n");
  client.print("User-Agent: Mozilla/5.0\r\n");
  client.print("Transfer-Encoding: chunked\r\n");
  client.print("\r\n");
}

void endChunkedRequest(SSLClient client)
{
  client.print("0\r\n");
  client.print("\r\n");
}
void chunkedRequest(SSLClient client, uint8_t *buffer, size_t len)
{
  client.print("c350");
  client.print("\r\n");
  client.write(buffer, len);
  client.print("\r\n");
}

But when I try it on my esp32 I get the error "connection reset by peer".
So if you know the differences between the two clients/code please let me know.
Thanks

ESP32 after a few days starts returning error Certificate is expired or not yet valid

I have a sketch that runs on many ESP32 devices with a W5500.

All devices have been running fine for approx 1 month with no issues.

Recently all the devices have started reporting the following error when attempting to connect to my server.

20:53:51.515 -> (SSLClient)(SSL_WARN)(connect): Arduino client is already connected? Continuing anyway...
20:53:51.515 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
20:53:51.515 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
20:53:51.515 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Certificate is expired or not yet valid.

The server ssl certificate is a letsencrypt certificate and is working properly. Double checking the certificate expire data is about 90 days from the current date. The certificates have recently renewed.

First I forced the certificate to renew again, and rebooted the devices, no change.

Then I re-uploaded firmware to one of the devices. No changes were made to the firmware. The trust anchor was not changed. - The device started working.

I then forced the certificate to renew again. This did not cause the problem to come back for that device and all other devices were un-changed.

As a check I exported the trust anchor again and compared to the existing trust anchor. The trust anchor content did not change.

So my problem is I have many devices that are failing with the stated error "Certificate is expired or not yet valid". The only fix seems to be re-uploading unchanged firmware to the device.

Perhaps there is something with timestamp that validates the certificate at compile time and I need some way to update that time stamp?

The devices do not have an RTC and I do not set the time on them. I Can make a code change to do that, however uploading new code temporarily solves the issue so it would be hard for me to verify that is a fix.

Unstable connection via GSM network. The signal quality is strong enough.

Describe the bug
The code is fine tuned, everything works, but the performance of SSL engine is not stable. Particularly, when the internet traffic is absent, the SSL engine goes stuck. The attached video shows the local terminal and the Telegram bot performance. Even having terminal data showing that the connection is lost, Telegram bot commands are able to reach to controller.

To Reproduce
NONE

Expected behavior
A clear and concise description of what you expected to happen. A reproducible sketch is especially helpful.

Screenshots/Serial Output
https://www.youtube.com/watch?v=gj2La91Q32Q

16:42:58.120 -> Initializing modem...
16:43:04.492 -> Modem Info: SIM800 R14.18
16:43:04.492 -> Own number: Connecting to APN: internet.beeline.am OK
16:43:10.319 -> Waiting for network...
16:43:10.319 -> GPRS status: connected
16:43:10.319 -> Local IP:10.105.116.13
16:43:10.319 -> Requesting current network time
16:43:10.319 -> Year: 2021	Month: 12	Day: 7
16:43:10.319 -> Hour: 16	Minute: 43	Second: 9
16:43:10.319 -> Timezone: 4.00
16:43:10.319 -> Difference between two dates is 738495 days
16:43:21.490 -> got response
16:43:21.490 -> Message text: /start
16:43:29.926 -> got response
16:43:29.926 -> Message text: Engine
16:43:48.514 -> got response
16:43:48.514 -> Message text: Arm Car
16:43:53.305 -> MOTION DETECTED!!!
16:43:53.305 -> MOTION DETECTED!!!
16:43:53.305 -> MOTION DETECTED!!!
16:43:53.305 -> MOTION DETECTED!!!
16:43:53.305 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.406 -> MOTION DETECTED!!!
16:43:53.440 -> MOTION DETECTED!!!
16:43:53.547 -> MOTION DETECTED!!!
16:43:53.580 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.614 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.648 -> MOTION DETECTED!!!
16:43:53.716 -> MOTION DETECTED!!!
16:43:53.716 -> MOTION DETECTED!!!
16:43:53.716 -> MOTION DETECTED!!!
16:43:53.716 -> MOTION DETECTED!!!
16:44:13.956 -> (SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
16:44:13.956 -> (SSLClient)(SSL_ERROR)(m_update_engine): 0
16:44:13.956 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:44:13.956 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:13.956 -> (SSLClient)(SSL_ERROR)(available): SSL engine failed to update.
16:44:13.956 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.003 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.003 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.003 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.003 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.003 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.003 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.003 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.036 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.036 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.036 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.036 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.036 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.070 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.070 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.070 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.070 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.070 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.104 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.104 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.104 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.104 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.104 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.163 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.163 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.163 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.163 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.163 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.163 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.163 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.163 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.197 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.197 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.197 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.197 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.197 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.197 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.258 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.258 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.258 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.258 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.258 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.258 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.258 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.258 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.258 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.258 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.307 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.307 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.307 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.307 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.307 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.307 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.307 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.341 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.341 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.341 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.341 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.341 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.374 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.374 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.374 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.374 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.374 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.374 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.458 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.458 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.458 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.458 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.458 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.458 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.458 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.458 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.458 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.458 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.458 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.458 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.506 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.506 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.506 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.506 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.506 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.506 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.506 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.541 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.541 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.541 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.541 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.541 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.541 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.587 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.587 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.587 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.587 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.587 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.587 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.587 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.636 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.636 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.636 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.636 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.636 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.636 -> (SSLClient)(SSL_ERROR)(available): Cannot operate if the write error is not reset: 
16:44:14.636 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:14.678 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:44:14.678 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:15.667 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:44:15.711 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:44:19.369 -> got response
16:44:19.369 -> Message text: GoogleMAP
16:48:07.094 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
16:48:07.094 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:48:07.094 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Caller-provided parameter is incorrect.
16:48:08.079 -> (SSLClient)(SSL_WARN)(connect): Arduino client is already connected? Continuing anyway...
16:49:04.086 -> got response
16:49:04.086 -> Message text: Arm Car
16:49:39.437 -> (SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
16:49:39.437 -> (SSLClient)(SSL_ERROR)(m_update_engine): 0
16:49:39.437 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:49:39.437 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:49:39.478 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating with write error: 
16:49:39.478 -> (SSLClient)(SSL_WARN)(m_run_until): 4
16:49:39.478 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:49:39.478 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
16:49:39.478 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:49:39.512 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:49:39.512 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:49:39.512 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:49:40.547 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:49:40.547 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:19.737 -> (SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
16:52:19.770 -> (SSLClient)(SSL_ERROR)(m_update_engine): 0
16:52:19.770 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:19.770 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:19.940 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating with write error: 
16:52:19.940 -> (SSLClient)(SSL_WARN)(m_run_until): 4
16:52:19.940 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:52:19.940 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
16:52:19.974 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:19.974 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:19.974 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:19.974 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:21.003 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:21.003 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:29.569 -> (SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
16:52:29.569 -> (SSLClient)(SSL_ERROR)(m_update_engine): 0
16:52:29.569 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:29.569 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:29.704 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating with write error: 
16:52:29.738 -> (SSLClient)(SSL_WARN)(m_run_until): 4
16:52:29.738 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:52:29.738 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
16:52:29.738 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:29.772 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:29.772 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:29.772 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:30.791 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:52:30.791 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:52:49.735 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
16:52:49.735 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:52:49.735 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Caller-provided parameter is incorrect.
16:52:50.758 -> (SSLClient)(SSL_WARN)(connect): Arduino client is already connected? Continuing anyway...
16:56:09.845 -> (SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
16:56:09.845 -> (SSLClient)(SSL_ERROR)(m_update_engine): 0
16:56:09.879 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:09.879 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:09.913 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating with write error: 
16:56:09.913 -> (SSLClient)(SSL_WARN)(m_run_until): 4
16:56:09.913 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:56:09.913 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
16:56:09.947 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:09.947 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:09.947 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:09.947 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:10.975 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:10.975 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:24.859 -> (SSLClient)(SSL_ERROR)(m_update_engine): Error reading bytes from m_client. Write Error: 
16:56:24.859 -> (SSLClient)(SSL_ERROR)(m_update_engine): 0
16:56:24.859 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:24.893 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:25.334 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating with write error: 
16:56:25.368 -> (SSLClient)(SSL_WARN)(m_run_until): 4
16:56:25.368 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:56:25.368 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
16:56:25.368 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:25.368 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:25.402 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:25.402 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:26.421 -> (SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
16:56:26.421 -> (SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
16:56:47.282 -> (SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
16:56:47.316 -> (SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
16:56:47.316 -> (SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 307`

Context (please complete the following information):

  • Device Type: ESP32
  • Arduino Core Version: 1.8.16
  • Relevant Library Versions [PubSubClient, etc.]
  • SSLClient Version: Up-to-date

Additional context
Add any other context about the problem here.

AWS MQTT, wifi ESP32

i was look ways to use this library with SIM868, and integrate with tinyGsm Library, but before star the test with the GPRS properly, i have decided test with the native wifi in ESP32,easy to test :)

The problem is, when i use the native library(WiFiClientSecure) it's work well, but using SSLClient its say that the is write erro

To test i have this code

#define SSL

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include "PassWordFile.h"
#include <SSLClient.h>
#include "certificates.h"
#include "cert.h"
#include "CA.h"

void pubSubCheckConnect(PubSubClient pubSubClient);

#if defined(SSL)
SSLClientParameters mTLS = SSLClientParameters::fromPEM(certificate_pem_crt, sizeof certificate_pem_crt, private_pem_key, sizeof private_pem_key);
WiFiClient clientnoSSL;
SSLClient client(clientnoSSL, TAs, (size_t)TAs_NUM, 27);
#else
WiFiClientSecure client;
#endif

PubSubClient pubSubClient(ENDPOINTAWS, 8883, client);

void setup()
{
     Serial.begin(115200);
    delay(50);
    Serial.printf("\r\nESP32 AWS IoT Example\r\n");
    Serial.printf("SDK version: %s\r\n", ESP.getSdkVersion());
    Serial.print("Connecting to ");
    Serial.print(WIFI_NAME);
    WiFi.begin(WIFI_NAME, WIFI_PASS);
    WiFi.waitForConnectResult();
    Serial.print(", WiFi connected, IP address: ");
    Serial.println(WiFi.localIP());
    Serial.printf("free heap :%i\r\n",esp_get_free_heap_size());
    pubSubClient.setBufferSize(2048);
#if !defined(SSL)
    client.setCACert(rootCA);
    client.setCertificate(certificate_pem_crt);
    client.setPrivateKey(private_pem_key);
#endif
}

unsigned long lastPublish;
int msgCount;

void loop()
{
    while (!pubSubClient.connected())
        pubSubClient.connect("ESPthingXXXX");
    pubSubClient.loop();
    client.flush();
    if (millis() - lastPublish > 10000)
    {
        String msg = String("{\"Hello from ESP32\": \"") + ++msgCount + String("\"}");
        boolean rc = pubSubClient.publish("outTopic", msg.c_str());
        client.flush();
        Serial.print("Published, rc=");
        Serial.print((rc ? "OK: " : "FAILED: "));
        Serial.println(msg);
        lastPublish = millis();
    }
}

void pubSubCheckConnect(PubSubClient pubSubClient)
{
    if (!pubSubClient.connected())
    {
        Serial.print("PubSubClient connecting to: ");
        Serial.print(ENDPOINTAWS);
        while (!pubSubClient.connected())
        {
            Serial.print(".");
            pubSubClient.connect("ESPthingXXXX");
            delay(1000);
        }
        Serial.println(" connected");
        pubSubClient.subscribe("inTopic");
    }
    pubSubClient.loop();
}

when the first line is on, my output is:


ESP32 AWS IoT Example
SDK version: v3.2.3-14-gd3e562907
Connecting to 350, WiFi connected, IP address: 192.168.1.105
free heap :201884
(SSLClient)(SSL_ERROR)(m_run_until): SSL internals timed out! This could be an internal error, bad data sent from the server, or data being discarded due to a buffer overflow. If you are using Ethernet, did you modify the library properly (see README)?
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR

with first line commented:

ESP32 AWS IoT Example
SDK version: v3.2.3-14-gd3e562907
Connecting to 350, WiFi connected, IP address: 192.168.1.105
free heap :211080
Published, rc=OK: {"Hello from ESP32": "1"}
Published, rc=OK: {"Hello from ESP32": "2"}

where i need use flush?
and make the mqtt size bigger is equal to make the client buffer sizer bigger?

Using
C++2017 to compile.
Last versions of PubSubClient, SSLClient Linrarys

mqtt.2030.ltsapis.goog:8883 generate/download does not work

Describe the bug
I am trying connect SSL client to mqtt.2030.ltsapis.goog. I am having troubles with pycert_bearssl.py

python3 ./pycert_bearssl.py download --port 8883 mqtt.2030.ltsapis.goog returns error

I downloaded primary(https://pki.goog/gtsltsr/gtsltsr.crt) and backup(https://pki.goog/gsr4/GSR4.crt) certs from https://cloud.google.com/iot/docs/how-tos/mqtt-bridge#downloading_mqtt_server_certificates and converted them to PEM format.
python3 ./pycert_bearssl.py convert --no-search ./primary.pem ./backup.pem returns next error:

Traceback (most recent call last):
  File "./pycert_bearssl.py", line 151, in <module>
    pycert_bearssl()
  File "/home/andrii/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/andrii/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/andrii/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/andrii/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/andrii/.platformio/penv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "./pycert_bearssl.py", line 147, in convert
    cert_util.x509_to_header(root_certs, cert_var, cert_length_var, output, keep_dupes)
  File "/home/andrii/Projects/DokoSens/firmware/scripts/cert_util.py", line 267, in x509_to_header
    n_bytes_str = bytes_to_c_data(numbers.n.to_bytes(pubkey.bits() // 8, byteorder="big"))
AttributeError: 'EllipticCurvePublicNumbers' object has no attribute 'n'

As I understand provided above certs are EllipticCurve instead of RSA. As EllipticCurve has x and y fields and not n and e script fails.

Expected behavior
That would be great to make this script generate correct certificates.h with different kinds of certificates.

Context (please complete the following information):

Certificate to use AWS via MQTT

I'm using on ESP8266 a sketch like this one: https://github.com/Ameba8195/Arduino/blob/master/hardware_v2/libraries/MQTTClient/examples/amazon_awsiot_basic/amazon_awsiot_basic.ino, where the certificates are simply stored in flash as they are downloaded from the server:

char* rootCABuff = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" \
"yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" \
...

char* certificateBuff = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIDWTCCAkGgAwIBAgIUE1UsPqN2mfvCGh2DLX2HWs3NOIYwDQYJKoZIhvcNAQEL\n" \
"BQAwTTFLMEkGA1UECwxCQW1hem9uIFdlYiBTZXJ2aWNlcyBPPUFtYXpvbi5jb20g\n" \
...

char* privateKeyBuff = \
"-----BEGIN RSA PRIVATE KEY-----\n" \
"MIIEpAIBAAKCAQEA0zz9/MUl5mhLbIh/RjKx4WpSWfA3A2yDQbhT7eZQ+PjuiCze\n" \
"MsMUDbTw/zlLeqd8NpRjnnfBhjcFwiUHOmnLu+y2uBqlM7EfZz82uT9B8OqD+BQF\n" \
...

Now I need to port the code to an STM32 board (Nucleo-144 429ZI).
Because the STM32Ethernet library still does not support secure connections, they suggested me to use this library instead.
I read the documentation here: https://github.com/OPEnSLab-OSU/SSLClient/blob/master/TrustAnchors.md but my still limited knowledge about certificates doesn't allow me to fully understand how should I fill in the Trust Anchors from the above certificates.

Discarded unread data to favor a write operation

I'm using an Arduino Due with Seeed Studio W5500 Ethernet Shield which has an Internal 32Kbytes Memory for TX/RX Buffers.

My project involves only transmitting and receiving MQTT from a local broker, although I got to connect and transmit some MQTT messages I'm getting this error spammed on the serial and cannot receive any MQTT messages.

(SSLClient)(SSL_WARN)(m_run_until): Discarded unread data to favor write operation

signal-2021-05-16-175438 (2)

at first I thought I messed up modifying the Ethernet Library from Arduino so I tried using EthernetLarge library fork provided by the guide but I'm still getting the same error and still cant receive MQTT

I just followed the provided example .ino file for MQTT with TLS, Is there something I missed doing to prevent this

HTTPS GET request - ESP8266 - ENC28j60

Hi, I'm traying to compile the SSLClient library in my ESP8266 but I have this message:

Several libraries were found for "EthernetLarge.h"
using: /home/xx/Arduino/libraries/EthernetLarge-master
Several libraries were found for "SSLClient.h"
using: /home/xx/Arduino/libraries/SSLClient
Several libraries were found for "SPI.h"
using: /home/xx/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/SPI
exit status 1

Error compiling for card NodeMCU 1.0 (ESP-12E Module).

I'm wanna use the SSLClient library to query a HTTPS web service using an ESP8266 (NodeMCU 1.0 ESP-12E) with a ENC28j60 (Ethernet module), I wanna know if this is possible.

Thanks.

vector: No such file or directory

Describe the bug
when trying to compiles it does not compile, I don't know if i need another lib or something, I only installed this library and try to compile but is not working

To Reproduce
Write some steps to reproduce the behavior. Be sure to include the vant hardware required, if any.

  1. Compile using the library

Expected behavior
Compile fine

Screenshots/Serial Output
In file included from F:\Bibliotecas\Documentos\Arduino\libraries\SSLClient\src/SSLClient.h:23:0,
from F:\Bibliotecas\Documentos\Arduino\jesusMQTT_4relaysNANO\jesusMQTT_4relaysNANO.ino:4:
F:\Bibliotecas\Documentos\Arduino\libraries\SSLClient\src/SSLClientParameters.h:31:10: fatal error: vector: No such file or directory
#include <" vector ">
^~~~~~~~
compilation terminated.
exit status 1
Error compilando para la tarjeta Arduino Nano.

I'm Using Arduino Nano with Ethernet Shield.

SSLClient fails to validate end-entity trust anchor

Hi and thanks for this great software!

I'm trying to to use SSLClient to connect to my local mosquitto server with selfsigned certs but I can't figure out whats wrong. I already looked at #7 and I think I've done everything right (but then it would work, so I'm missing something).

I'm on a SAMD21 M0 Mini with a W5500 ethernet adapter, using the EthernetMQTT example with these changes (changed all Serial.print... to SerialUSB.print. Had to do that in SSLClient.cpp and SSLClient.h also):

const char my_cert[] = 
("-----BEGIN CERTIFICATE-----\r\n"
"MIIFITCCBAmgAwIBAgIJAO0g55P8M5rqMA0GCSqGSIb3DQEBDQUAMGAxGTAXBgNV\r\n"
"BAMMEEhvbWUgTVFUVCBicm9rZXIxFDASBgNVBAoMC2hhbGxncmVuLmZpMQswCQYD\r\n"
"VQQLDAJOQTEgMB4GCSqGSIb3DQEJARYRbmlja2VAaGFsbGdyZW4uZmkwHhcNMTgx\r\n"
"MDI3MTE0NjAyWhcNMzIxMDIzMTE0NjAyWjBeMRcwFQYDVQQDDA5ob21lYXV0b21h\r\n"
"dGlvbjEUMBIGA1UECgwLaGFsbGdyZW4uZmkxCzAJBgNVBAsMAk5BMSAwHgYJKoZI\r\n"
"hvcNAQkBFhFuaWNrZUBoYWxsZ3Jlbi5maTCCASIwDQYJKoZIhvcNAQEBBQADggEP\r\n"
"ADCCAQoCggEBAK9wUAhKjkDiu871VR+FhBv9Txl7iqdYT2WY/f7Vj6VBbozhde8V\r\n"
"N8uKB6Jm5xaVBo+LLtbXlUSAEdNt0kiJgH9ycXwHOMki17wEezix61VFmvnSVzOf\r\n"
"bFrWVIRfWKbMVZObPUy6Y2QN0Kiu4Sbk6KXVRAxZQRnFnwMWp3OfeocA1+Tpcup9\r\n"
"Jg/ZHIhSVPNRe6H3sEcRNZc2/DdvBwBGr50mIFqKBSu+3h+x3MXMySSEHwnxnSvH\r\n"
"W06aWpCqTXNiQxHYUh/tu/Dz+VVJrafyRhxv4VI+uaDUZqZTHh3Y5NFrMNbrBz6/\r\n"
"3Er1H28SAnNeWGLS0WaM/BIFybBRI0p0TwcCAwEAAaOCAd4wggHaMAwGA1UdEwEB\r\n"
"/wQCMAAwEQYJYIZIAYb4QgEBBAQDAgZAMAsGA1UdDwQEAwIF4DAhBglghkgBhvhC\r\n"
"AQ0EFBYSQnJva2VyIENlcnRpZmljYXRlMB0GA1UdDgQWBBSAz2y4oL4ARoAswHK+\r\n"
"O7NWPNUU/DCBkgYDVR0jBIGKMIGHgBQb9pcbqsJG+nyMDccdo9Eki47Y36FkpGIw\r\n"
"YDEZMBcGA1UEAwwQSG9tZSBNUVRUIGJyb2tlcjEUMBIGA1UECgwLaGFsbGdyZW4u\r\n"
"ZmkxCzAJBgNVBAsMAk5BMSAwHgYJKoZIhvcNAQkBFhFuaWNrZUBoYWxsZ3Jlbi5m\r\n"
"aYIJAIfLPF8FuBU8MEoGA1UdEQRDMEGHBMCoARKHEP6AAAAAAAAAs0vEHTLdZWCH\r\n"
"BH8AAAGHEAAAAAAAAAAAAAAAAAAAAAGHBMCoARKCCWxvY2FsaG9zdDCBhgYDVR0g\r\n"
"BH8wfTB7BgMrBQgwdDAcBggrBgEFBQcCARYQaHR0cDovL2xvY2FsaG9zdDBUBggr\r\n"
"BgEFBQcCAjBIMBAWCU93blRyYWNrczADAgEBGjRUaGlzIENBIGlzIGZvciBhIGxv\r\n"
"Y2FsIE1RVFQgYnJva2VyIGluc3RhbGxhdGlvbiBvbmx5MA0GCSqGSIb3DQEBDQUA\r\n"
"A4IBAQCPNpR9kNGmgHjSQmOg3iSrI5eykeie350LM9HIDLJ2Q2fzNDzUS+UQOBpI\r\n"
"1OR1ByyAndL58kGOM+9cyBVVpWOIVWsbCKSORLBDE/1OIvxCZyomDyEF3wuBjoGH\r\n"
"2jJGbOHjiX2Ij3gYTB63jFXyLDTeaEErUSz4jqfSrg/eId7q0OQbKOWUOaUrWty5\r\n"
"8QvrippU8qNKUJWf4RtlTqRyFCm2BUIoHol/S1jRopYiI67MVu3AcjFoRhm3HMyS\r\n"
"t9MOr6lKbkvw2CQdWLe5ml8Dh+tvsW1lPyb9ee4DHHtcMBro7egLsLBI/wcSnaGW\r\n"
"3iJGJ0K6dXZFICqjoyqwr718SXx3\r\n"
"-----END CERTIFICATE-----\r\n");
const char my_key[] = 
("-----BEGIN RSA PRIVATE KEY-----\n"
"MIIEpAIBAAKCAQEAr3BQCEqOQOK7zvVVH4WEG/1PGXuKp1hPZZj9/tWPpUFujOF1\r\n"
"7xU3y4oHombnFpUGj4su1teVRIAR023SSImAf3JxfAc4ySLXvAR7OLHrVUWa+dJX\r\n"
"M59sWtZUhF9YpsxVk5s9TLpjZA3QqK7hJuTopdVEDFlBGcWfAxanc596hwDX5Oly\r\n"
"6n0mD9kciFJU81F7ofewRxE1lzb8N28HAEavnSYgWooFK77eH7HcxczJJIQfCfGd\r\n"
"K8dbTppakKpNc2JDEdhSH+278PP5VUmtp/JGHG/hUj65oNRmplMeHdjk0Wsw1usH\r\n"
"Pr/cSvUfbxICc15YYtLRZoz8EgXJsFEjSnRPBwIDAQABAoIBAA0qSnc00RQBb8KK\r\n"
"GocxB8bp7WOmJ7ODJwIixvy2nf7yuA8OZEE6wGMfyo7fVfwV1tYyxaMNrn/jdHL/\r\n"
"TMZwuxnVRrrd997wJGxRkcWhZF2TyZtxs2WGUyVF7DW6yfZKYymefq0hV5AMkVn3\r\n"
"NaIrj2HSbTbYA9ChSdt7ebltgE5dG//huKI9NOMdE5bfWr4c/ZLUG063I48KnAZl\r\n"
"wlM7dioutO9Zl7u04aPNh76v/km9XihdjgyWAbPozPc7t30n0zEdq0IHTNRgEAUC\r\n"
"MSPavmZVqreqt5DI9NXHwytlj6pGqUUQVxHUAgrqzAdZo8gLGbR3UQL2T90E/Sna\r\n"
"Zq+UUnECgYEA3YN0Nqy/xnVISRx5ayF569H7+nglRiXeEyF9GPVtrDgyoEBhFzeS\r\n"
"SmSoeRlDBHCwHRcCCdFIAxWc6iiN3JjlarWTr+RceK7U39eFIywvJDOaxvgOcMjY\r\n"
"v/dyap0bAsf5OnS1SoGRnqLiPXHx1XHiWDERm0yV8Cpv/F6nG83El6UCgYEAysCF\r\n"
"wvVKEWcI0zc5VjkhY+N3zJCkZjhJp8ILtfsjez2NoA9oy4fe18f9O3op8FZbj4yC\r\n"
"WGvhZhLBosr6QYsW5+1z+605P1Gw7vWwO3aqwhMYt8wci0pEBocT32A44fD2g8aW\r\n"
"93JgHXBvzSjeN4mBvWFHVCyIBmv3IgTAYl+xLDsCgYEApKtHJinveonPTcJkJJbD\r\n"
"OuJj7kOIeghGeXRIudghSoiQYf7Z7ld6YeFIOJXl8xQOZ+Glu0SfwuM7Pfsd0mK7\r\n"
"EUOgYX5im7hkOW7O42HCPag7JDRdD8zPDI3XuZfG759XD/SYnKWLaiFuC/17qI+7\r\n"
"kpIPo6IgSGRT0YlPsuSZg50CgYEAsrbGcNVTR0mhrsOjp4vOEcUD6O2p62w8CEHz\r\n"
"nqHSYaQc/PP4NEb8NwlR/iYtZ2pHZJ2+mv/ketuXkM4HjtRyCVb1f+btahGwusEX\r\n"
"aSKtW0oH5KJmmqSIl5RjAOdI3GdQc1EN6ukHLYvZEGawkRWEpZBklh52e+qYuISl\r\n"
"q1Cb09cCgYAsDhuoOMWWXbczhW5HW+Xk6DQydcDRwBQtPaiTPScxZUS2pMdug6Pt\r\n"
"5glzQDndmc0/MyWw3tJF3EFEf32d0n6pCeyX09xdZ+ZzKU3Z58luJxOE0RJKmWt4\r\n"
"PUiDJkZVRtd/aIhLt08LAVHV9aKRt7Lu/ub6gB7c0bC0lirF2QIlXQ==\r\n"
"-----END RSA PRIVATE KEY-----\r\n");
SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key);

byte mac[] = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };

IPAddress mqttServer(10, 10, 10, 10);
const int mqttPort = 8883;

EthernetClient ethClient;
SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, A0, 1, SSLClient::SSL_DUMP);
PubSubClient client(mqttServer, mqttPort, callback, ethClientSSL);

I generated my certificates.h like this:

openssl s_client -showcerts -connect 10.10.10.10:8883 </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem
python3 ./Arduino/libraries/SSLClient/tools/pycert_bearssl/pycert_bearssl.py convert --no-search mycertfile.pem

And this is the output from the serial monitor;

Attempting MQTT connection...(SSLClient)(SSL_WARN)(connect): Using a raw IP Address for an SSL connection bypasses some important verification steps. You should use a domain name (www.google.com) whenever possible.
(SSLClient)(SSL_INFO)(connect): Base client connected!
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDREC
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 5
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   Connection closed
(SSLClient)(SSL_WARN)(m_run_until): Terminating because the ssl engine closed
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Chain could not be linked to a trust anchor. See https://github.com/OPEnSLab-OSU/SSLClient/blob/master/TrustAnchors.md
failed, rc=-2 try again in 5 seconds

I've also tried with only \n my_cer and my_key. Any ideas on what I'm doing wrong?

Calls to stop before connected cause lockups.

Describe the bug
Calling sslClient.stop() when !sslClient.connected() causes buffer overflow, even after previously successful connection (and disconnect).

To Reproduce
EthernetClient mqttEthClient;
Ethernet.init(14);
SSLClient sslClient(mqttEthClient, TAs_HTTPS, (size_t)TAs_NUM_HTTPS, RANDOM_DATA_PIN);
sslClient.stop();

Expected behavior
Calls to stop should exit gracefully or ignore the request if already exited.

Context (please complete the following information):

  • Device Type - ESP32/Teensy4
  • Arduino Core Version - Teensyduino 1.52
  • Relevant Library Versions - PubSubClient
  • SSLClient Version - v1.6.6

Additional context
Discovered while trying to make the library robust to internet connectivity issues. Removing jump_handshake in br_ssl_engine_close prevents this (not a fix).

Extreme slow compilation with SSLClient in Arduino IDE

Since I started using the SSLClient library, the compilation of my project became unworkabley slow: +3 minutes.
I enabled compile logging and this(*) is what I get EVERY time I re-compile.
I use Arduino IDE 1.8.16 and ESP32 core v1.0.6.

(*) I can only show a small part of the logging, as it exceeds the 64k upload limit.
But I get a whole lot more of these lines...

Is there anything I can do to speedup the compile process again?

Thanks

"C:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/config" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_trace" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_update" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/asio" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bootloader_support" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/coap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/console" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/driver" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/efuse" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-tls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_adc_cal" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_event" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_ota" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_ringbuf" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_websocket_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/espcoredump" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ethernet" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/expat" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fatfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freemodbus" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freertos" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/heap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/idf_test" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/jsmn" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/json" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/libsodium" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/log" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/lwip" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mbedtls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mdns" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/micro-ecc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mqtt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/newlib" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nghttp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nvs_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/openssl" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protobuf-c" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protocomm" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/pthread" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/sdmmc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/smartconfig_ack" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/soc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spi_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spiffs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcp_transport" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcpip_adapter" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ulp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/unity" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/vfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wear_levelling" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wifi_provisioning" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wpa_supplicant" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/xtensa-debug-module" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32-camera" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fb_gfx" -std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -c -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10816 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"ESP32_DEV\"" "-DARDUINO_VARIANT=\"esp32\"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\cores\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\variants\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\SPI\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\ArduinoJson\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\mWebSockets\\src" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\WiFi\\src" "C:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src\\SSLClient.cpp" -o nul
"C:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/config" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_trace" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_update" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/asio" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bootloader_support" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/coap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/console" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/driver" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/efuse" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-tls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_adc_cal" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_event" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_ota" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_ringbuf" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_websocket_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/espcoredump" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ethernet" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/expat" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fatfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freemodbus" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freertos" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/heap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/idf_test" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/jsmn" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/json" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/libsodium" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/log" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/lwip" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mbedtls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mdns" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/micro-ecc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mqtt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/newlib" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nghttp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nvs_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/openssl" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protobuf-c" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protocomm" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/pthread" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/sdmmc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/smartconfig_ack" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/soc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spi_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spiffs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcp_transport" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcpip_adapter" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ulp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/unity" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/vfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wear_levelling" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wifi_provisioning" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wpa_supplicant" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/xtensa-debug-module" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32-camera" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fb_gfx" -std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -c -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10816 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"ESP32_DEV\"" "-DARDUINO_VARIANT=\"esp32\"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\cores\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\variants\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\SPI\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\ArduinoJson\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\mWebSockets\\src" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\WiFi\\src" "C:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src\\SSLClientParameters.cpp" -o nul
"C:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/config" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_trace" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_update" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/asio" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bootloader_support" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/coap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/console" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/driver" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/efuse" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-tls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_adc_cal" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_event" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_ota" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_ringbuf" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_websocket_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/espcoredump" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ethernet" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/expat" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fatfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freemodbus" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freertos" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/heap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/idf_test" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/jsmn" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/json" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/libsodium" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/log" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/lwip" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mbedtls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mdns" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/micro-ecc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mqtt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/newlib" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nghttp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nvs_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/openssl" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protobuf-c" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protocomm" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/pthread" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/sdmmc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/smartconfig_ack" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/soc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spi_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spiffs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcp_transport" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcpip_adapter" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ulp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/unity" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/vfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wear_levelling" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wifi_provisioning" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wpa_supplicant" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/xtensa-debug-module" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32-camera" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fb_gfx" -std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -c -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10816 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"ESP32_DEV\"" "-DARDUINO_VARIANT=\"esp32\"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\cores\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\variants\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\SPI\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\ArduinoJson\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\mWebSockets\\src" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\WiFi\\src" "C:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src\\TLS12_only_profile.c" -o nul
"C:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/config" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_trace" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/app_update" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/asio" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bootloader_support" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/bt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/coap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/console" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/driver" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/efuse" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-tls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_adc_cal" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_event" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_http_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_ota" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_https_server" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_ringbuf" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp_websocket_client" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/espcoredump" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ethernet" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/expat" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fatfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freemodbus" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/freertos" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/heap" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/idf_test" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/jsmn" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/json" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/libsodium" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/log" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/lwip" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mbedtls" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mdns" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/micro-ecc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/mqtt" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/newlib" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nghttp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/nvs_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/openssl" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protobuf-c" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/protocomm" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/pthread" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/sdmmc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/smartconfig_ack" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/soc" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spi_flash" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/spiffs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcp_transport" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/tcpip_adapter" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/ulp" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/unity" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/vfs" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wear_levelling" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wifi_provisioning" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/wpa_supplicant" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/xtensa-debug-module" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp32-camera" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/esp-face" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6/tools/sdk/include/fb_gfx" -std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -c -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10816 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"ESP32_DEV\"" "-DARDUINO_VARIANT=\"esp32\"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\cores\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\variants\\esp32" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\SPI\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\ArduinoJson\\src" "-IC:\\Program Files (x86)\\Arduino\\libraries\\Ethernet\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src" "-IC:\\Users\\mvrm\\Documents\\Arduino\\libraries\\mWebSockets\\src" "-IC:\\Users\\mvrm\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\WiFi\\src" "C:\\Users\\mvrm\\Documents\\Arduino\\libraries\\SSLClient\\src\\bearssl\\src\\aead\\ccm.c" -o nul

Example compilation error

Hello,

I am going to use the library in my project on Arduino Due. First I tried to build EthernetMQTT example, but it failed. Among a dozen of warnings there is an error:
In constructor 'SSLClientParameters::SSLClientParameters(const char*, size_t, const char*, size_t, bool)':
\Documents\Arduino\libraries\SSLClient\src\SSLClientParameters.cpp:84:121: error: cannot convert 'br_skey_decoder_context' to 'uint32_t {aka long unsigned int}' in initialization, m_key_struct{ make_key_from_der( is_der ? std::vector(key, key + key_len) : make_vector_pem(key, key_len) ) } {}
Could you help me with finding the source of the problem?

Looking forward to your reply,
Oleg I.

SSLClient::connected "Socket was dropped unexpectedly" because m_client is done but SSLClient still has data in buffer

Describe the bug
SSLClient::connected stops with "Socket was dropped unexpectedly" because m_client is done and returns false for connected() but SSLClient still has unread data in buffer.

To Reproduce
I tested SSLClient library with my networking libraries EthernetENC and WiFiEspAT. Both end with this error in EthernetHTTPS.ino example. EthernetENC reads more data than WiFiEspAT but both stop reading before all data are read.
If I remove if (!client.connected()) { from the example, all data are read.

Expected behavior
It is a valid state that m_client is already closed and doesn't have data so it returns false for connected(). So SSLClient::connected should not stop() and report disconnect while it still has data in buffer. connected() is specified to return true while data are available. https://www.arduino.cc/en/Reference/ClientConnected

Screenshots/Serial Output

Waiting for connection to WiFi
..
Connected to WiFi network.
connecting to www.arduino.cc...
Took: 4103
c_con: 1 br_con: 1 
(it repeats many times)
c_con: 1 br_con: 1
HTTP/1.1 200 OK
Date: Sun, 25 Apr 2021 14:05:03 GMT
Content-Type: text/plain
c_con: 0 br_con: 1
(SSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)
c_con: 0 br_con: 0

disconnecting.
c_con: 0 br_con: 0
Received 80 bytes in 0.6543, rate = 0.12 kbytes/second

Context:

  • Arduino Core Version: Arduino SAMD core 1.8.9
  • Relevant Library Versions: WiFiEspAT 1.3.1 and EthernetENC 2.0.1 (GitHub master)
  • SSLClient Version 1.6.11

Selfsigned certificate usage

Is your question related to a problem? Please describe.
To omit the dependency from trusted certificate issuers (theirs certificates are valid for short period of time) I did a decision to use own made self-signed certificate for my domain. This own certificate has 10 years long period of life. This is vital subject. Otherwise, I was forced to update the firmware of my controllers on certificate expiration, either, directly or by air, which is not convenient. Controllers in my project are tied with mqtt broker on my domain and are using secured mqtt protocol.
For now, the certificate generating engine at https://openslab-osu.github.io/bearssl-certificate-utility/ does not return the code for www.bmwgate.tk
What to do to get this subject fixed, please advise.

Can't get AWSIoT example working on ESP32

I'm almost certainly doing something dumb, but I've been at it for a while and I can't figure out what my problem is.

I'm using the AWSIoT example, substituting wifi for ethernet in order to use an ESP32 without an ethernet shield. I've included EthernetLarge.h. I think I generated my trust anchors correctly using pycert_bearssl.py. I know that the certs work because I can connect using wificlientsecure just fine. However I need this for another board (automation direct P1AM) which does not have Wifi so I need to figure out how to get the connection working without using wificlientsecure.

Any help greatly appreciated!

Code:

#include <SPI.h>
#include <EthernetLarge.h>
#include <SSLClient.h>
#include <PubSubClient.h>
#include "certificates.h" // This file is created using AmazonRootCA1.pem from https://www.amazontrust.com/repository/AmazonRootCA1.pem

// Wifi Info
// ***********************************************************
const char* ssid       = "...";
const char* password   = "...";

#define THING_NAME "..."
#define MQTT_PACKET_SIZE  1024

const char my_cert[] = \
"-----BEGIN CERTIFICATE-----\n" \ 
"MIIDWTCCAkGgAwIBAgIUCfyz78MYjtdWqZzv/uYK49pfIvYwDQYJKoZIhvcNAQEL\n" \
...
"-----END CERTIFICATE-----\n";

const char my_key[] = \
"-----BEGIN RSA PRIVATE KEY-----\n" \ 
"MIIEowIBAAKCAQEAoy+7EXAGAnSekgHJuo9eWzL8/Le1KNSxbhY5BtiOIAT+8FdC\n" \
...
"IVwcDl+IbWqy/Eg1Ux1olMYXoG1+iB5VRK2MpBiwoOrvvRE0Q3nD" \
"-----END RSA PRIVATE KEY-----\n";

SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key);

const char* mqttServer = "xxxxxxxxxx-ats.iot.us-east-2.amazonaws.com";

void callback(char* topic, byte* payload, unsigned int length) 
{
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) 
  {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

WiFiClient ethClient;
SSLClient ethClientSSL(ethClient, TAs, (size_t)TAs_NUM, 5, 1, SSLClient::SSL_INFO);
PubSubClient mqtt(mqttServer, 8883, callback, ethClientSSL);

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

void reconnect() 
{
  while (!mqtt.connected()) 
  {
    Serial.print("Attempting MQTT connection...");
    if (mqtt.connect("arduinoClient")) 
    {
      Serial.println("connected");
    } 
    else 
    {
      Serial.print("failed, rc=");
      Serial.print(mqtt.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);
    }
  }
}

void connectToWifi() {
  // Connect to Wi-Fi
  Serial.println("Connecting to Wifi");
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected.");
}

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  
  connectToWifi();

  ethClientSSL.setMutualAuthParams(mTLS);
  mqtt.setBufferSize(MQTT_PACKET_SIZE);
  
}

void loop() {
  if (!mqtt.connected()) 
  {
    reconnect();
  }
  mqtt.loop();
}

Serial output:

...WiFi connected.
Attempting MQTT connection...(SSLClient)(SSL_INFO)(connect): Base client connected!
(SSLClient)(SSL_INFO)(m_start_ssl): about to inject random data from pin
(SSLClient)(SSL_INFO)(m_start_ssl): entropy injected!
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDREC
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): m_run changed state:
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_INFO)(m_run_until): Expected bytes count: 
(SSLClient)(SSL_INFO)(m_run_until): 5
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   SENDREC
(SSLClient)(SSL_INFO)(m_print_br_state): (SSLClient)(SSL_INFO)(m_print_br_state): State: 
   RECVREC
(SSLClient)(SSL_ERROR)(m_run_until): SSL internals timed out! This could be an internal error, bad data sent from the server, or data being discarded due to a buffer overflow. If you are using Ethernet, did you modify the library properly (see README)?
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_BR_WRITE_ERROR
(SSLClient)(SSL_ERROR)(m_start_ssl): Failed to initlalize the SSL layer
(SSLClient)(SSL_ERROR)(m_print_br_error): Unknown error code: 0
failed, rc=-2 try again in 5 seconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.