This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC3200MODLAUNCHXL: SSL connection error

Part Number: CC3200MODLAUNCHXL

Tool/software: Code Composer Studio

Hai,

       I need a support for  ssl demo sample code in ccs. i tried  to connect google server with  server name is "www.google.com

      i got return value for sl_connect is -370 and certificate flashed with name  "/cert/google.der".

     Did anyone  tried ssl demo in ccs before ,please reply. i am waiting for the reply as fast possible ,thank you.

static long ssl()
{
SlSockAddrIn_t Addr;
int iAddrSize;
unsigned char ucMethod = SL_SO_SEC_METHOD_SSLV3;
unsigned int uiIP,uiCipher = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA;
long lRetVal = -1;
int iSockID;

GPIO_IF_LedConfigure(LED1|LED3);

GPIO_IF_LedOff(MCU_RED_LED_GPIO);
GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);

lRetVal = InitializeAppVariables();
ASSERT_ON_ERROR(lRetVal);

//
// Following function configure the device to default state by cleaning
// the persistent settings stored in NVMEM (viz. connection profiles &
// policies, power policy etc)
//
// Applications may choose to skip this step if the developer is sure
// that the device is in its default state at start of applicaton
//
// Note that all profiles and persistent settings that were done on the
// device will be lost
//
lRetVal = ConfigureSimpleLinkToDefaultState();
if(lRetVal < 0)
{
if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
UART_PRINT("Failed to configure the device in its default state \n\r");

return lRetVal;
}

UART_PRINT("Device is configured in default state \n\r");

CLR_STATUS_BIT_ALL(g_ulStatus);

///
// Assumption is that the device is configured in station mode already
// and it is in its default state
//
lRetVal = sl_Start(0, 0, 0);
if (lRetVal < 0 || ROLE_STA != lRetVal)
{
UART_PRINT("Failed to start the device \n\r");
return lRetVal;
}

UART_PRINT("Device started as STATION \n\r");

//
//Connecting to WLAN AP
//
lRetVal = WlanConnect();
GPIO_IF_LedOff(MCU_RED_LED_GPIO);
if(lRetVal < 0)
{
UART_PRINT("Failed to establish connection w/ an AP \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

UART_PRINT("Connection established w/ AP and IP is aquired \n\r");

//Set time of the device for certificate verification.
lRetVal = set_time();
if(lRetVal < 0)
{
UART_PRINT("Unable to set time in the device");
return lRetVal;
}


lRetVal = sl_NetAppDnsGetHostByName(g_Host, strlen((const char *)g_Host),
(unsigned long*)&uiIP, SL_AF_INET);

if(lRetVal < 0)
{
UART_PRINT("Device couldn't retrive the host name \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(GOOGLE_DST_PORT);
Addr.sin_addr.s_addr = sl_Htonl(uiIP);
iAddrSize = sizeof(SlSockAddrIn_t);
//
// opens a secure socket
//
iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
if( iSockID < 0 )
{
UART_PRINT("Device unable to create secure socket \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

//
// configure the socket as SSLV3.0
//
lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, &ucMethod,\
sizeof(ucMethod));
if(lRetVal < 0)
{
UART_PRINT("Device couldn't set socket options \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}


//
//configure the socket as RSA with RC4 128 SHA
//
lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_SECURE_MASK, &uiCipher,\
sizeof(uiCipher));
if(lRetVal < 0)
{
UART_PRINT("Device couldn't set socket options \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

//
//configure the socket with GOOGLE CA certificate - for server verification
//
lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, \
SL_SO_SECURE_FILES_CA_FILE_NAME, \
SL_SSL_CA_CERT_FILE_NAME, \
strlen(SL_SSL_CA_CERT_FILE_NAME));

if(lRetVal < 0)
{
UART_PRINT("Device couldn't set socket options \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

lRetVal = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, \
SO_SECURE_DOMAIN_NAME_VERIFICATION, \
g_Host, strlen((const char *)g_Host));
if( lRetVal < 0 )
{
UART_PRINT("Device couldn't set socket options \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

/* connect to the peer device - Google server */
lRetVal = sl_Connect(iSockID, ( SlSockAddr_t *)&Addr, iAddrSize);

if(lRetVal < 0)
{
UART_PRINT("Device couldn't connect to Google server \n\r");
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
return lRetVal;
}

GPIO_IF_LedOff(MCU_RED_LED_GPIO);
GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
return SUCCESS;
}