hello
i am getting some error while implimening SSL
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x90c
load:0x403ce710,len:0x2624
entry 0x403cc710
=== MC60 MQTT SSL FIX START ===
AT
OK
ATE0
OK
AT+CFUN=1
OK
AT+CPIN?
+CPIN: READY
OK
AT+CREG?
+CREG: 0,5
OK
AT+CGATT=1
OK
AT+QIDEACT
DEACT OK
AT+QIREGAPP=“VILESIM”,“”,“”
OK
AT+QIACT
OK
AT+QILOCIP
10.67.253.43
AT+QMTCFG=“keepalive”,0,60
OK
AT+QSSLCFG=“cacert”,2,“”
ERROR
AT+QSECDEL=“UFS:cacert.pem”
OK
Calculated Certificate Length: 1940
AT+QSECWRITE=“UFS:cacert.pem”,1940,100
CONNECT
+QSECWRITE: 1940,6e4f
OK
AT+QSSLCFG=“cacert”,2,“UFS:cacert.pem”
OK
AT+QSSLCFG=“seclevel”,2,1
OK
AT+QSSLCFG=“sslversion”,2,4
OK
AT+QSSLCFG=“ciphersuite”,2,“0xFFFF”
OK
AT+QSSLCFG=“ignorertctime”,1
OK
AT+QMTCFG=“SSL”,0,1,2
OK
AT+QMTOPEN=0,“mqtt-lets.balwaan.com”,8883
OK
+QMTOPEN: 0,-1
MQTT SSL CONNECT FAILED
SSL code -
Phase 1: Network & GPRS Attachment
Before doing anything with SSL, the modem must be “online” and have a valid IP address.
AT→ Verifies modem communication.ATE0→ Disables command echoing to keep responses clean.AT+CFUN=1→ Sets the modem to full functionality.AT+CPIN?→ Checks if the SIM card is ready.AT+CREG?→ Checks if the modem is registered on the cellular network.AT+CGATT=1→ Attaches to the GPRS service.AT+QIDEACT→ Deactivates the previous PDP context (clean slate).AT+QIREGAPP="VILESIM","",""→ Sets the APN for your provider.AT+QIACT→ Activates the GPRS context.AT+QILOCIP→ Requests the local IP address (confirms connection).
Phase 2: Certificate Management (SSL Storage)
This phase uploads the ISRG Root X1 certificate to the modem’s internal flash memory (UFS).
AT+QSSLCFG="cacert",2,""→ Clears any existing CA cert assigned to SSL context 2.AT+QSECDEL="UFS:cacert.pem"→ Deletes any old certificate file from memory.AT+QSECWRITE="UFS:cacert.pem",1939,100→ Commands the modem to prepare for 1,939 bytes of data.
- The modem will reply with
CONNECT. You then stream the raw text of the certificate. - After sending the data, the modem returns
OK.
Phase 3: SSL Configuration & MQTT Connection
This links the certificate to the MQTT client and performs the secure handshake.
AT+QMTCFG="keepalive",0,60→ Sets MQTT keep-alive to 60 seconds.AT+QSSLCFG="cacert",2,"UFS:cacert.pem"→ Assigns your uploaded cert to SSL context 2.AT+QSSLCFG="seclevel",2,1→ Sets security level to 1 (Verify Server).AT+QSSLCFG="sslversion",2,4→ Enables all SSL/TLS versions.AT+QSSLCFG="ciphersuite",2,"0xFFFF"→ Enables all supported cipher suites.AT+QSSLCFG="ignorertctime",1→ Crucial: Tells the modem to ignore its internal clock (often wrong on startup) when checking cert expiration.AT+QMTCFG="SSL",0,1,2→ Binds MQTT Client 0 to use SSL Context 2.AT+QMTOPEN=0,"com",8883→ Opens a TCP connection on the secure port.
- Wait for URC:
+QMTOPEN: 0,0
AT+QMTCONN=0,"abcd","mc60device","fghi"→ Logs into the MQTT broker.
- Wait for URC:
+QMTCONN: 0,0,0
Phase 4: Data Transmission
AT+QMTPUB=0,0,0,0,"Status"→ Prepares to publish a message.
- The modem will show a
>prompt. You send your message followed by0x1A(Ctrl+Z).