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.

[参考译文] CC3220SF:HTTPS 服务器问题

Guru**** 2644125 points

Other Parts Discussed in Thread: CC3220SF

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1576780/cc3220sf-issues-with-https-server

器件型号:CC3220SF


工具/软件:

您好、TI 论坛!

过去几年里、我一直在为我的应用在 CC3220SF 上运行 HTTP 服务器。 服务器工作正常并且非常稳定。 但是、我现在需要将其从 HTTP 迁移到 HTTPS。

在过去的几周中、我一直在尝试根据 SDK 中提供的示例进行这种过渡。 一切似乎都在调试模式下正确初始化、但传入的请求未得到正确处理。  我还在客户端禁用了证书验证、但在握手过程中遇到意外的 EOF 错误。

为了进行故障排除、我使用了openssl s_client该命令来检查连接、看起来证书可能存在一些问题。

我目前使用以下设置:

  • SimpleLink SDK 6.10.05

  • Code Composer Studio 12.1.0

  • 颁发 dummy-trusted-ca-cert

  • 密钥: dummy-trusted-ca-cert-key

下面是负责启用 HTTPS 服务器的代码部分。 我怀疑问题可能与证书如何加载到文件系统有关。 但是、该SlNetSock_secAttribSet函数会0同时返回这两次、因此此时没有错误指示。

如果对可能出现的问题有任何见解或指导、我们将非常感激。

   int rc;
    HTTPServer_Handle srv = 0;
    struct sockaddr_in addr;
    (void)noargs;
    SlNetSockSecAttrib_t* secAttribs = NULL;

    srv = HTTPServer_create (handlerTable, 1, NULL);

    memset (&addr, 0, sizeof (addr));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = htonl (INADDR_ANY);
    addr.sin_port = htons (BIONET_HTTP_PORT_SSL);

    secAttribs = SlNetSock_secAttribCreate ();
    if (secAttribs == NULL){
        debug_printf("  SlNetSock_secAttribCreate failed\r\n");
        pthread_exit (0);
        return NULL;
    }

    // Loading the buffers into the security attributes object
    rc = SlNetSock_secAttribSet (secAttribs, SLNETSOCK_SEC_ATTRIB_LOCAL_CERT, "/dummy-trusted-ca-cert", strlen("/dummy-trusted-ca-cert")+1);
    debug_printf("  SLNETSOCK_SEC_ATTRIB_LOCAL_CERT: status = %d\r\n", rc);

    rc = SlNetSock_secAttribSet (secAttribs, SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY, "/dummy-trusted-ca-cert-key", strlen("/dummy-trusted-ca-cert-key")+1);
    debug_printf("  SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY: status = %d\r\n", rc);

    HTTPServer_enableSecurity(srv, secAttribs, true);

    if (srv){
        bionet_log (BN_LOG_DEBUG, "HTTP Server Ready.\r\n");
        #ifdef __BIONET_DEBUG__
                debug_printf ("{\"httpServer\": {\"status\":\"ready\"}}");
        #endif  // __BIONET_DEBUG__
        debug_printf ("{\"httpServer\": {\"status\":\"ready\"}}");
        rc = HTTPServer_serveSelect (srv, (struct sockaddr *)&addr, sizeof(addr), BIONET_HTTP_BACKLOG);

        if (rc != 0){
            bionet_log (BN_LOG_ERROR, "Unable to start HTTP server!\r\n");
            #ifdef __BIONET_DEBUG__
                        debug_printf ("{\"httpServer\": {\"error\":\"unable to start!\"}}");
            #endif  // __BIONET_DEBUG__
            debug_printf ("{\"httpServer\": {\"error\":\"unable to start!\"}}");
        }

        HTTPServer_delete (&srv);
    }

    pthread_exit (0);

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我通过更改加载证书的方式、成功地与 HTTPS 服务器建立了通信。 我将密钥存储为.pem文件并SlNetIf_loadSecObj在调用之前使用加载它们SlNetSock_secAttribSet

    我仍然看到一些与握手方法相关的警告、但总体而言、它似乎有效、现在我可以与服务器通信。