Hi community
I hope you are fine and well.
I have already tried this lib and it is working well for connecting an ethernet shield enc28j60 with tls to aws (mqtts) for esp32 micro
but now I have the need to call this istruction…
SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key);
not at the beginning of the module (as shown in the example above) but at runtime inside another function.
I explain you why i need to do this it is because i want to read from a txt file the certificates and keys for the connection instead of change the code manually for every device that is deployed.
But when i try to do this
uint8_t setup_ethernet(void)
{
uint8_t result_connection = 0;
/*retrieve security info for aws from memory*/
Load_secrets_from_memory();
SSLClientParameters mTLS = SSLClientParameters::fromPEM(my_cert, sizeof my_cert, my_key, sizeof my_key);
/*authentication on aws*/
ethClientSSL.setMutualAuthParams(mTLS);
Ethernet.init(ETH_CS, ðernetSPI, ETH_SCLK, ETH_MISO, ETH_MOSI);
Serial.begin(115200);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
Ethernet.begin(mac, TIME_OUT_WAITING_ETH_CABLE);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
result_connection = 1;
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true)
{
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF)
{
result_connection = 1;
Serial.println("Ethernet cable is not connected.");
}
Serial.print("Joined LAN with IP ");
Serial.println(Ethernet.localIP());
Serial.flush();
setup_time();
// Create a message handler
mqtt_istance.setCallback(callback);
return result_connection;
}
my esp32 is crashing and restarting…
I wonder if in your opinion it is possible to call that instruction once i have read the txt file…
Thanks a lot for your help