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.

Connecting to server using HTTPS

I am having issues with connecting to server using HTTPS. It works on an older server but when we switched to a firebase server we seem to be having some issues. The HTTP works.

I have gone back and taken the HTTP_client_demo so that i know its none of the code I added. I got it connecting to server with HTTP then added the code that is in the wiki so that it is possible to use HTTPS. I get a -102 error every time i try to connect. The certs are correct and updated. Tried different ports. still keep getting same -102 error. 

here is my HTTP connect function. 

//*****************************************************************************
//
//! Function to connect to HTTP server
//!
//! \param httpClient - Pointer to HTTP Client instance
//!
//! \return Error-code or SUCCESS
//!
//*****************************************************************************
static int ConnectToHTTPServer(HTTPCli_Handle httpClient)
{
long lRetVal = -1;
struct sockaddr_in addr;


#ifdef USE_PROXY
struct sockaddr_in paddr;
paddr.sin_family = AF_INET;
paddr.sin_port = htons(PROXY_PORT);
paddr.sin_addr.s_addr = sl_Htonl(PROXY_IP);
HTTPCli_setProxy((struct sockaddr *)&paddr);
#endif

/* Resolve HOST NAME/IP */
lRetVal = sl_NetAppDnsGetHostByName((signed char *)HOST_NAME,
strlen((const char *)HOST_NAME),
&g_ulDestinationIP,SL_AF_INET);
if(lRetVal < 0)
{
ASSERT_ON_ERROR(GET_HOST_IP_FAILED);
}

SlDateTime_t dt;

/* Set current Date to validate certificate */
dt.sl_tm_day = 28;
dt.sl_tm_mon = 10;
dt.sl_tm_year = 2016;
dt.sl_tm_hour = 2;
dt.sl_tm_min = 39;
dt.sl_tm_sec = 2;
sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
sizeof(SlDateTime_t), (unsigned char *)(&dt));

#define SL_SSL_CA_CERT "/cert/c1.cer"
struct HTTPCli_SecureParams sparams;
/* Set secure TLS connection */
/* Security parameters */
sparams.method.secureMethod = SL_SO_SEC_METHOD_SSLv3_TLSV1_2;//SL_SO_SEC_METHOD_SSLv3_TLSV1_2;
sparams.mask.secureMask = SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA;//SL_SEC_MASK_SECURE_DEFAULT;SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA //SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
strncpy(sparams.cafile, SL_SSL_CA_CERT, sizeof(SL_SSL_CA_CERT));
sparams.privkey[0] = 0;
sparams.cert[0] = 0;
sparams.dhkey[0] = 0;
HTTPCli_setSecureParams(&sparams);

/* Set up the input parameters for HTTP Connection */
addr.sin_family = AF_INET;
addr.sin_port = htons(HOST_PORT);
addr.sin_addr.s_addr = sl_Htonl(g_ulDestinationIP);

/* Testing HTTPCli open call: handle, address params only */
HTTPCli_construct(httpClient);
lRetVal = HTTPCli_connect(httpClient, (struct sockaddr *)&addr, HTTPCli_TYPE_TLS, NULL);
if (lRetVal < 0)
{
UART_PRINT("Connection to server failed. error(%d)\n\r", lRetVal);
ASSERT_ON_ERROR(SERVER_CONNECTION_FAILED);
}
else
{
UART_PRINT("Connection to server created successfully\r\n");
}

return 0;
}