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:
- 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);
}
-
APP_DEBUG("Start PDP Contex Active\n"); ret = RIL_NW_SetGPRSContext(0);
Get Response:
← Set GPRS PDP context, ret=0 →
-
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”. →
- 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.