1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

ftps:// support added

This commit is contained in:
Daniel Stenberg 2001-03-29 08:16:55 +00:00
parent 34efa74a59
commit b1328430c9
3 changed files with 33 additions and 18 deletions

View File

@ -78,6 +78,7 @@
#endif
#include "strequal.h"
#include "ssluse.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@ -316,6 +317,14 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
return result;
}
if(conn->protocol & PROT_FTPS) {
/* FTPS is simply ftp with SSL for the control channel */
/* now, perform the SSL initialization for this socket */
if(Curl_SSLConnect(conn))
return CURLE_SSL_CONNECT_ERROR;
}
/* The first thing we do is wait for the "220*" line: */
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
@ -337,8 +346,6 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
set a valid level */
sec_request_prot(conn, data->krb4_level);
data->cmdchannel = fdopen(conn->firstsocket, "w");
if(sec_login(conn) != 0)
infof(data, "Logging in with password in cleartext!\n");
else
@ -1702,16 +1709,9 @@ size_t Curl_ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
strcat(s, "\r\n"); /* append a trailing CRLF */
#ifdef KRB4
if(conn->sec_complete && conn->data->cmdchannel) {
bytes_written = sec_fprintf(conn, conn->data->cmdchannel, s);
fflush(conn->data->cmdchannel);
}
else
#endif /* KRB4 */
{
bytes_written = swrite(fd, s, strlen(s));
}
bytes_written=0;
Curl_write(conn, fd, s, strlen(s), &bytes_written);
return(bytes_written);
}

View File

@ -1399,6 +1399,8 @@ static CURLcode Connect(struct UrlData *data,
#ifdef USE_SSLEAY
else if(strnequal(conn->gname, "HTTPS", 5))
strcpy(conn->protostr, "https");
else if(strnequal(conn->gname, "FTPS", 4))
strcpy(conn->protostr, "ftps");
#endif /* USE_SSLEAY */
else if(strnequal(conn->gname, "TELNET", 6))
strcpy(conn->protostr, "telnet");
@ -1668,8 +1670,19 @@ static CURLcode Connect(struct UrlData *data,
conn->curl_done = Curl_http_done;
conn->curl_close = Curl_http_close;
}
else if(strequal(conn->protostr, "FTP")) {
else if(strequal(conn->protostr, "FTP") ||
strequal(conn->protostr, "FTPS")) {
char *type;
if(strequal(conn->protostr, "FTPS")) {
#ifdef USE_SSLEAY
conn->protocol |= PROT_FTPS;
#else
failf(data, "libcurl was built with SSL disabled, ftps: not supported!");
return CURLE_UNSUPPORTED_PROTOCOL;
#endif /* !USE_SSLEAY */
}
conn->port = (data->use_port && allow_port)?data->use_port:PORT_FTP;
conn->remote_port = PORT_FTP;
conn->protocol |= PROT_FTP;
@ -1678,6 +1691,12 @@ static CURLcode Connect(struct UrlData *data,
!data->bits.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel ftp operations through the proxy, we
switch and use HTTP operations only */
if(conn->protocol & PROT_FTPS) {
/* FTPS is a hacked protocol and does not work through your
ordinary http proxy! */
failf(data, "ftps does not work through http proxy!");
return CURLE_UNSUPPORTED_PROTOCOL;
}
conn->curl_do = Curl_http;
conn->curl_done = Curl_http_done;
conn->curl_close = Curl_http_close;

View File

@ -207,6 +207,7 @@ struct connectdata {
#define PROT_DICT (1<<6)
#define PROT_LDAP (1<<7)
#define PROT_FILE (1<<8)
#define PROT_FTPS (1<<9)
#ifdef ENABLE_IPV6
struct addrinfo *hp; /* host info pointer list */
@ -293,7 +294,6 @@ struct connectdata {
document headers */
#ifdef KRB4
enum protection_level command_prot;
enum protection_level data_prot;
enum protection_level request_data_prot;
@ -553,10 +553,6 @@ struct UrlData {
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
char *krb4_level; /* what security level */
#ifdef KRB4
FILE *cmdchannel;
#endif
struct timeval keeps_speed; /* this should be request-specific */
/* 'connects' will be an allocated array with pointers. If the pointer is