Mc60 SSL TCP create connection in open cpu mode error

Hi Good day
I encountered a problem to connect TLS - TCP and I tried to do the all things according to document GSM SSL Application Note, but unfortunately I failed to connect To the server.

my code is:


  1. set private key in RAM by command:

#define KeyFilenameinRAM “RAM:key.pem”
#define key_length 2048

u8 key[2048];
// This variable is to store the data of certificate received from uart.

Key_Handeler = Ql_FS_OpenRAMFile(KeyFilenameinRAM, QL_FS_READ_WRITE | 

QL_FS_CREATE, key_length); // open file for store config file in it.

if (Key_Handeler >= QL_RET_OK)
{
    _Ret = Ql_FS_Seek(Key_Handeler, OFFSET, QL_FS_FILE_BEGIN);
    _Ret = Ql_FS_Truncate(Key_Handeler);

    _Ret = Ql_FS_Seek(Key_Handeler, OFFSET, QL_FS_FILE_BEGIN);
    _Ret = Ql_FS_Write(Key_Handeler, key, Ql_strlen(key), &writeedlen);
    Ql_FS_Flush(Key_Handeler);
    Ql_FS_Close(Key_Handeler);

}


  1.       APP_DEBUG("Start PDP Contex Active\n");
         ret = RIL_NW_SetGPRSContext(0);
    

Get Response:
← Set GPRS PDP context, ret=0 →


  1.      ret = RIL_NW_SetAPN(1, APN_NAME, APN_USERID, APN_PASSWD);
         APP_DEBUG("<-- Set GPRS APN, ret=%d -->\r\n", ret); 
    

Get Response:
← Set GPRS APN, ret=0 →


strATLen = Ql_sprintf(strAT, “AT+QIREGAPP\0”);

strATLen = Ql_sprintf(strAT, “AT+QIACT\0”);

Ql_sprintf(strAT, “AT+QILOCIP\r\n”);
ret = Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), Getloacl_ip, &errCode, 0);

Get Response:
← Send AT:AT+QILOCIP, ret = 0 →
← Local Ip:“22.231.143.80”. →


  1. send AT+QSSLCFG and Get Response:
    .
    .
    .
    .
    response:
    ← Send AT:AT+QSSLCFG=“ignorertctime”,1, ret = 0 →

← Send AT:AT+QSSLCFG=“sslversion”,0,4, ret = 0 →

← Send AT:AT+QSSLCFG=“ciphersuite”,0,“0xFFFF”, ret = 0 →

← Send AT:AT+QSSLCFG=“seclevel”,0,1, ret = 0 →


Ql_sprintf(strAT, “AT+QSECREAD="RAM:Key.pem"\r\n”);
ret = Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), check_the_root_calback, &errCode, 0);

← Send AT:AT+QSECREAD=“RAM:Key.pem”, ret = 0 →
+QSECREAD: 0,304a

>>>>> Why get “The certificate or key is wrong” ???

NOTE: The contents of the certificate file are saved without any changes in file “RAM:key.pem” that get through UART.


← Send AT:AT+QSSLCFG=“clientkey”,0,“RAM:Key.pem”, ret = 0 →

SOKET: AT+QSSLOPEN=1,0,“185.191.79.7”,11000,0
OK
+QSSLOPEN: 1,-1

I tested with both files .pem and .cer and got an error. Each two files are concatenated. Please check .

if you have an example, please share it with me.

Certificate.rar (1.4 KB)

thank’s a lot.

Hi
I fixed problem +QSECREAD: 0,304a because of not using command AT+QSECWRITE=, but still the connection does not open

Ql_sprintf(strAT, “AT+QSECWRITE="RAM:Key.pem",%d,%d\r\n”, keylen, timeout); // TO WRITE CERTIFICATE TO RAM
ret = Ql_RIL_SendATCmd(strAT, Ql_strlen(strAT), ATResponse_SSL_handler_CLIENTKEY_WRITE, &errCode, 0);

static s32 ATResponse_SSL_handler_CLIENTKEY_WRITE(char *line, u32 len, void *userdata)
{
char *pHead = NULL;
pHead = Ql_RIL_FindString(line, len, “CONNECT”);
APP_DEBUG(“RES: %s\n\r”, line);
if (pHead)
{
Ql_RIL_WriteDataToCore((u8 *)key, keylen);
return RIL_ATRSP_SUCCESS; // wait for OK
}
.
.
.
}

← Send AT:AT+QSECREAD=“RAM:Key.pem”, ret = -1 →
+QSECREAD: 1,3952

But after sending commands again, the connection is not opened

SOKET: AT+QSSLOPEN=1,0,“185.191.79.7”,11000,0

OK

+QSSLOPEN: 1,-1