Witam. Pobralem cURL i chcialbym sprawdzic jego mozliwosci. Przetestowalem rozne rzeczy, m.in. pobieranie/uploadowanie pliku po przez protokol FTP oraz pobieranie plikow z HTTP, a teraz zabrałem sie za FTP wspieranego przez SSL/TLS czyli FTPS i mam problem z pobraniem pliku. Przeszperalem google, robilem wedle wskazowek/przykladow, a wciaz plik, ktory probuje sciagnac z lokalnej maszyny nie pobiera sie. Siedze na windows 7 32bit.
size_t DownloadData(char *data, size_t size, size_t nmemb, FILE *pFile)
{
return fwrite(data,size,nmemb,pFile);
}
int main()
{
FILE *file = fopen("e:\\plik_pobrany.txt","wb");
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl_easy_init();
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
curl_easy_setopt(curl,CURLOPT_URL,"ftps://uzytkownik:haslo@localhost/plik_do_pobrania.txt");
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,false);
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,false);
curl_easy_setopt(curl,CURLOPT_FTP_SSL,CURLFTPSSL_ALL);
curl_easy_setopt(curl,CURLOPT_FTPSSLAUTH,CURLFTPAUTH_DEFAULT);
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,DownloadData);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,file);
curl_easy_perform(curl);
fclose(file);
curl_easy_cleanup(curl);
curl_global_cleanup();
printf("process finished\n");
return 0;
}
Tutaj otrzymane logi:
Adding handle: conn: 0x52feb8
Adding handle: send: 0
Adding handle: recv: 0
Curl_addHandleToPipeline: length: 1
- Conn 0 (0x52feb8) send_pipe: 1, recv_pipe: 0
About to connect() to localhost port 990 (#0)
Trying ::1...
Connected to localhost (::1) port 990 (#0)
schannel: SSL/TLS connection with localhost port 990 (step 1/3)
schannel: disable server certificate revocation checks
schannel: verifyhost setting prevents Schannel from comparing the supplied target name with the subject names in server certificates. Also disables SNI.
schannel: sending initial handshake data: sending 113 bytes...
schannel: sent initial handshake data: sent 113 bytes
schannel: SSL/TLS connection with localhost port 990 (step 2/3)
schannel: failed to receive handshake, need more data
schannel: SSL/TLS connection with localhost port 990 (step 2/3)
schannel: encrypted data buffer: offset 511 length 4096
schannel: sending next handshake data: sending 198 bytes...
schannel: SSL/TLS connection with localhost port 990 (step 2/3)
schannel: encrypted data buffer: offset 128 length 4096
schannel: encrypted data length: 69
schannel: SSL/TLS handshake complete
schannel: SSL/TLS connection with localhost port 990 (step 3/3)
schannel: incremented credential handle refcount = 1
schannel: stored credential handle in session cache
schannel: client wants to read 16384 bytes
schannel: encrypted data buffer: offset 69 length 16384
schannel: encrypted data got 122
schannel: encrypted data buffer: offset 191 length 16384
schannel: decrypted data length: 36
schannel: decrypted data added: 36
schannel: decrypted data cached: offset 36 length 16384
schannel: encrypted data length: 122
schannel: encrypted data cached: offset 122 length 16384
schannel: decrypted data length: 54
schannel: decrypted data added: 54
schannel: decrypted data cached: offset 90 length 16384
schannel: encrypted data length: 37
schannel: encrypted data cached: offset 37 length 16384
schannel: decrypted data buffer: offset 90 length 16384
schannel: decrypted data returned 90
schannel: decrypted data buffer: offset 0 length 16384
220 Welcome to Server
USER uzytkownik
421 Login time exceeded. Closing control connection.
We got a 421 - timeout!
Closing connection 0
schannel: shutting down SSL/TLS connection with localhost port 990
Send failure: Connection was aborted
schannel: failed to send close msg: Failed sending data to the peer (bytes written: -1)
schannel: clear security context handle
schannel: decremented credential handle refcount = 0