C 和卷发:无法接收握手,需要更多数据

C++ and Curl: Failed to receive handshake, need more data

本文关键字:多数据      更新时间:2023-10-16

我正在尝试使用凭据访问FTP。

我从未使用过卷发,对自己的工作有限,尽管我确实研究了许多我使用的功能。我曾经在C中开发了一个有效的FTP客户端和服务器,但是它只是Unix,所以这主要是卷曲的问题(我真的想使用卷发,因为这必须是跨平台,而我不使用除了我自己包装所有东西,我敢肯定我必须知道如何最终使用卷发。)

到目前为止的代码(不包括标题文件,但我真的怀疑它是否需要,由于明显的原因,密码和登录隐藏。它们在Filezilla中进行了测试)

    bool FTPClient::DownloadFile()
    {
CURL *curl;
CURLcode res;
char buffer[CURL_ERROR_SIZE + 1] = {};
struct FtpFile ftpfile =
{
    "test",
    NULL
};

curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) 
{
    curl_easy_setopt(curl, CURLOPT_URL,
        "https://[login]:[password]@lifesanctuary.eu/Update");
    curl_easy_setopt(curl, CURLOPT_PORT, 21);
    curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, buffer);
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
    if (CURLE_OK != res) 
    {
        //ERREUR
        fprintf(stderr, "erreur CURL %d:n%sn", res, buffer);
        curl_global_cleanup();
        return false;
    }
}
if (ftpfile.stream)
    fclose(ftpfile.stream);
curl_global_cleanup();
return true;
    }

输出:

    *   Trying 91.121.145.87...
    * TCP_NODELAY set
    * Connected to lifesanctuary.eu (91.121.145.87) port 21 (#0)
    * schannel: SSL/TLS connection with lifesanctuary.eu port 21 (step 1/3)
    * schannel: checking server certificate revocation
    * schannel: sending initial handshake data: sending 185 bytes...
    * schannel: sent initial handshake data: sent 185 bytes
    * schannel: SSL/TLS connection with lifesanctuary.eu port 21 (step 2/3)
    * schannel: failed to receive handshake, need more data
    * schannel: SSL/TLS connection with lifesanctuary.eu port 21 (step 2/3)
    * schannel: encrypted data got 53
    * schannel: encrypted data buffer: offset 53 length 4096
    * schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - Le jeton fourni Ó la fonction nÆest pas valide
    * Closing connection 0
    * schannel: shutting down SSL/TLS connection with lifesanctuary.eu port 21
    * schannel: clear security context handle
    erreur CURL 35:
    schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - Le jeton fourni Ó la fonction nÆest pas valide

我不知道问题是什么。我有潜在客户,搜寻了一点,得出的结论是,我找到了无关的东西,或者我根本不明白。

可能是因为加密,ssl/tls-我在该域中不太了解,设置服务器的人告诉我它使用了TLS,因此我为什么要把那行:

    curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");

,但我没有真正的想法如何做,看来" TLSV1"是我认为可以适合在我的上下文中的唯一参数。我怀疑这可能是问题。

另外,我认为另一个问题可能是与证书有关的。我不确定为什么,但是我确定我没有处理任何与证书有关的任何内容,而且我也不确定它们是什么。我知道,当我使用Filezilla登录FTP时,我会接受它,但是在这里我显然不是。

那是怎么回事?证书问题?加密问题?也许完全不同?提前致谢。

编辑: - 我假设这是证书问题,因为据我所知,HTTPS需要一个,而我在这方面没有任何事情, - 我正在考虑这可能是一个加密问题,因为此错误代码似乎主要是由此引起的 - 我完全不知道这可能是其他东西!

我认为交付该服务器的人的一系列错误信息是有原因的。有人告诉我多次使用" https://"使用。我正在关闭这个问题,因为它听起来更多是团队的问题,而不是代码中的问题。