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.

CC3100BOOST: Issues Implementing TLS/SSL on HTTP_Client example on CC3100boost + MSP430F5529

Part Number: CC3100BOOST

I am currently trying to get the http_client example working on CC3100Boost + MSP430F5529LP with TLS/SSL.  Additional details with respect to configuration is describe CC3100BOOST: Issue enabling secure connection (TLS/SSL) on CC3100Boost + MSP430F5529LP

As of now I believe the problem is somewhere in the function HTTPCli_connect() in httpcli.c routine. 

/*
 *  ======== HTTPCli_connect ========
 */
int HTTPCli_connect(HTTPCli_Struct *cli, const struct sockaddr *addr,
        int flags, const HTTPCli_Params *params)
{
    int skt;
    int ret;
    int slen;
    int sopt = 0;
    struct timeval tv;
    struct sockaddr *sa;
    Ssock_Struct ssock;

    xassert(cli != NULL);
    xassert(addr != NULL);

    if (proxyAddr.sa_family != 0) {
        sa = &proxyAddr;
    }
    else {
        sa = (struct sockaddr *)addr;
    }

    if (sa->sa_family == AF_INET6) {
        slen = sizeof(struct sockaddr_in6);
    }
    else {
        slen = sizeof(struct sockaddr_in);
    }

    if (!getCliState(cli, INPROGRESS_FLAG)) {

#ifndef HTTPCli_LIBTYPE_MIN
        if (params != NULL) {
            cli->shandle = params->shandle;
            cli->chandle = params->chandle;
            cli->rhandle = params->rhandle;

#ifndef __linux__
            cli->stackSize = params->stackSize;
            cli->priority  = params->priority;
#endif /* __linux__ */

            if (cli->chandle) {
                xassert(cli->shandle != NULL);
            }

            if (cli->shandle) {
                xassert(params->shandle->handle1xx != NULL);
                xassert(params->shandle->handle2xx != NULL);
                xassert(params->shandle->handle4xx != NULL);
            }
        }
#endif /* HTTPCli_LIBTYPE_MIN */

#ifdef __SL__
        if (flags & HTTPCli_TYPE_TLS) {
            sopt = SL_SEC_SOCKET;
        }
#endif /* __SL__ */

        skt = socket(sa->sa_family, SOCK_STREAM, sopt);
        if (isValidSocket(skt)) {
            Ssock_construct(&ssock, skt);
            cli->ssock = ssock;

            if (params != NULL && params->timeout) {
                tv.tv_sec = params->timeout;
                tv.tv_usec = 0;
                if (setsockopt(skt, SOL_SOCKET, SO_RCVTIMEO, &tv,
                        sizeof(tv)) < 0) {
                    HTTPCli_disconnect(cli);

                    return (HTTPCli_ESOCKETFAIL);
                }
            }

#ifdef __SL__
            /* In SL, the secure params have to be set before connect */
            if (flags & HTTPCli_TYPE_TLS) {
                ret = startSecureMode(cli);
                if (ret < 0) {
                    HTTPCli_disconnect(cli);

                    return (ret);
                }
            }
#endif /*__SL__*/
        }
        else {
            return (HTTPCli_ESOCKETFAIL);
        }
    }

    ret = connect(skt, sa, slen);

    if (ret < 0) {

#ifdef __SLP__
        if (errno(skt) == EINPROGRESS) {
            setCliState(cli, INPROGRESS_FLAG, 1);

            return (HTTPCli_EINPROGRESS);
        }
#endif /* __SLP__ */
        HTTPCli_disconnect(cli);

        return (HTTPCli_ECONNECTFAIL);
    }
    setCliState(cli, INPROGRESS_FLAG, 0);

#if !defined(__SL__) && !defined(__SLP__)
    /* In CYASSL, the secure params are set after connect */
    if (flags & HTTPCli_TYPE_TLS) {

        /* Tunnel using HTTP CONNECT for TLS through proxy */
        if (proxyAddr.sa_family != 0)  {
            ret = httpProxyTunnel(cli, addr);
            if (ret < 0) {
                return (HTTPCli_EPROXYTUNNELFAIL);
            }
        }

        ret = startSecureMode(cli);
        if (ret < 0) {
            HTTPCli_disconnect(cli);

            return (ret);
        }
    }

#endif /* __SL__  || __SLP__ */

#ifdef __SLP__
    if (params->rnotify) {
        ret = setsocknotify(skt, SO_READNOTIFY, params->rnotify, cli);
        if (ret < 0) {
            return (HTTPCli_ESETNOTIFYFAIL);
        }
    }

    if (params->wnotify) {
        ret = setsocknotify(skt, SO_WRITENOTIFY, params->wnotify, cli);
        if (ret < 0) {
            return (HTTPCli_ESETNOTIFYFAIL);
        }
    }

    if (params->enotify) {
        ret = setsocknotify(skt, SO_EXCEPTNOTIFY, params->enotify, cli);
        if (ret < 0) {
            return (HTTPCli_ESETNOTIFYFAIL);
        }
    }
#endif /* __SLP__ */


    return (0);
}



The software correctly call the connect() function which returns response of 0, but the code goes in to the code incorrectly executes the HTTPCli_disconnect() function. I have relisted the code section below.

 

  ret = connect(skt, sa, slen);

  if (ret < 0) {

#ifdef __SLP__
        if (errno(skt) == EINPROGRESS) {
            setCliState(cli, INPROGRESS_FLAG, 1);

            return (HTTPCli_EINPROGRESS);
        }
#endif /* __SLP__ */
        HTTPCli_disconnect(cli);

        return (HTTPCli_ECONNECTFAIL);
    }

Also below are list of defined macros for the project. 

Additionally I did also dig a little bit more deeper and found that the an error of -456 is generate a inside sl_connect() function in socket.c file. I believe the following line code is where the error is generated. 

/* wait for async and get Data Read parameters */
SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);