Unable to establish connection to MQTT broker on AWS IoT Core

Hello,
I’m trying to establish a connection to an MQTT broker hosted on AWS IoT Core from an HL7800 (v4.6.9) with an Orange SIM card. This requires an SSL connection, so I need to specify certificates. I’m able to connect to this MQTT broker via Python script.

The code previously connected to another MQTT broker which only had username/password authentication. After setting up TCP over SSL, I try to start a connection and get TCP Notification 13 = SSL connection error.

I’m using these commands to set up the SSL connection:
AT+KCNXCFG=1,"GPRS",""
AT+KSSLCRYPTO=0,8,1,8192,4,4,3,0 (note: profile_idx: 0, mkey_algo: ECDHE, auth_algo: RSA, enc_algo: AES-128-GCM, mac_algo: SHA-256, tls_ver: 1.2, auth: mutual, root_cert_idx: 0)
AT+KCERTSTORE=0, (int)sizeof(ROOT_CERT), 0 (root certificate)
ROOT_CERT
AT+KCERTSTORE=1, (int)sizeof(LOCAL_CERT), 0 (local certificate)
LOCAL_CERT payload
AT+KPRIVSTORE=0, (int)sizeof(LOCAL_PRIVATE_KEY) (private key)
LOCAL_PRIVATE_KEY payload

Connection to MQTT:
AT+KTCPCFG=1,3,AWS_IOT_MQTT_URL,8883
AT+KTCPCNX=1
AT+CSQ
AT+CEREG?
AT+CSQ

After the last command I get:
+KCNX_IND: 1,1,0
+KTCP_NOTIF: 1,13
+KTCP_NOTIF: 1,13
OK

Can you see any place where I’m doing something obviously wrong, or anything that I may be ignoring?

Notice that this is not the full list of commands I’m using, but only those that I believe could be the problematic ones. Happy to provide more details if neeed!

Thanks, Luca

You can download stunnel and run in client mode to test your cert and key with mutual authentication.
This can isolate if there is cert problem

Other user found it is working fine: