Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

SSLClientParameters mTLS not at beginning but at runtime #31

Closed

Description

@simogaspa84

Hi @khoih-prog ..

I hope you are fine and well.
I have already tried your lib and it is working well but 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 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, &ethernetSPI, 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

Activity

  1. Repository owner locked and limited conversation to collaborators on Dec 22, 2022
  2. converted this issue into a discussion #33 on Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions