You can chat about native SDK questions and issues here.

User avatar
By fDistorted
#70643 I am trying to write SSL key to device programmatically because I will need to change it dynamically.
I modified the script(it is in the attachments) from TLS guide to make keys for my server and variables to use in code to write them in flash.

the code looks like this.
Code: Select all #define SSL_CLIENT_KEY_ADDR 0x9A
 #define SSL_CA_ADDR 0x9C
#define INFO(format, ...) os_printf(format, ##__VA_ARGS__)

 int cacer_length = 507;
  INFO("Writing default SSL_CA_ADDR to memory. \r\n");
 unsigned char default_cacer[] = { 0x54, 0x4c,... 0xad, 0x38};
  switch(spi_flash_write(SSL_CA_ADDR * SPI_FLASH_SEC_SIZE, (uint32 *)&default_cacer, cacer_length)){
    case SPI_FLASH_RESULT_OK:
    INFO("SPI_FLASH_RESULT_OK\r\n");
    break;
    case SPI_FLASH_RESULT_ERR:
    INFO("SPI_FLASH_RESULT_ERR\r\n");
    break;
    case SPI_FLASH_RESULT_TIMEOUT:
    INFO("SPI_FLASH_RESULT_ERR\r\n");
    break;
    default:
    break;
  }

 unsigned char default_cer[] = { 0x54, 0x4c,... 0xad, 0x38};
int cer_length = 1787;
  INFO("Writing default SSL_CLIENT_KEY_ADDR to memory.  \r\n");
  switch (spi_flash_write(SSL_CLIENT_KEY_ADDR* SPI_FLASH_SEC_SIZE, (uint32*)&default_cer, cer_length)) {
  case SPI_FLASH_RESULT_OK:
      INFO("SPI_FLASH_RESULT_OK\r\n");
      break;
  case SPI_FLASH_RESULT_ERR:
      INFO("SPI_FLASH_RESULT_ERR\r\n");
      break;
  case SPI_FLASH_RESULT_TIMEOUT:
      INFO("SPI_FLASH_RESULT_ERR\r\n");
      break;
  default:
      break;
  }


but when I trying to run the writing of both of them it throws the Exception. I can write certs separately but when I am running the code to use this cert in the log I see this:
Image
Can somebody help me to solve this problem the right way?
You do not have the required permissions to view the files attached to this post.