应该通过https /端口443成功连接系统调用

时间:2018-11-08 11:12:02

标签: linux sockets ssl client-certificates rhodes

我使用的是旧的跨平台移动平台(Rhomobile),该平台支持api调用以检测是否存在可用的网络连接。源代码可用,我可以看到当我们进行调用以检测连接时,我们检查了OS级系统调用的结果,以针对给定的URL和端口建立套接字连接。由于我们的终结点是http,因此以前运行良好。现在,我们已将此迁移到https,并看到了一些奇怪的结果。拨打电话将是

    struct addrinfo hints, *result = NULL, *ptr = NULL;
    int sockfd = -1;
    memset(&hints,0,sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;
    char szPortAsString[5 + 1];
    snprintf(szPortAsString,5,"%d",m_iPort);
    char* szHost = new char[m_szHost.length() + 1];
    memset(szHost, 0, m_szHost.length() + 1);
    strcpy(szHost, m_szHost.c_str());
    int iResult = getaddrinfo(szHost, szPortAsString, &hints, &result);
    ...
    sockfd = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
    ...
    connect(sockfd, ptr->ai_addr, ptr->ai_addrlen);

,端口将为443。我不清楚是否接受连接(不需要传递任何数据)到https端点的连接(需要客户端证书)发送/接收数据。

代码可在此处找到:https://github.com/rhomobile/rhodes/blob/3f5cf6ffa90cf8c648ac19c954932d101fc56b42/lib/commonAPI/coreapi/ext/platform/android/jni/NetworkDetect.cpp

0 个答案:

没有答案
相关问题