--- lib/ssluse.c Thu Mar 11 07:00:31 2004 +++ lib/ssluse.c Thu May 13 13:05:31 2004 @@ -1108,7 +1108,16 @@ /* 1 is fine 0 is "not successful but was shut down controlled" <0 is "handshake was not successful, because a fatal error occurred" */ - if(1 != err) { + if (err == 1) { + /* we have been connected fine, get out of the connect loop */ + break; + } else if (err == 0) { + /* socket was shut down, so there's no reason to keep trying */ + char error_buffer[120]; /* OpenSSL documents that this must be at least + 120 bytes long. */ + int detail = SSL_get_error(connssl->handle, err); + failf(data, "SSL: err %d: detail: %d '%s'", err, detail, ERR_error_string(detail, error_buffer)); + } else { int detail = SSL_get_error(connssl->handle, err); if(SSL_ERROR_WANT_READ == detail) @@ -1117,9 +1126,11 @@ FD_SET(sockfd, &writefd); else { /* untreated error */ + char first_error_buffer[200]; char error_buffer[120]; /* OpenSSL documents that this must be at least 120 bytes long. */ + snprintf(first_error_buffer, sizeof(first_error_buffer), "first detail: %d '%s'", detail, ERR_error_string(detail, error_buffer)); detail = ERR_get_error(); /* Gets the earliest error code from the thread's error queue and removes the entry. */ @@ -1140,7 +1151,7 @@ return CURLE_SSL_CACERT; default: /* detail is already set to the SSL error above */ - failf(data, "SSL: %s", ERR_error_string(detail, error_buffer)); + failf(data, "SSL: err %d: %s detail: %d '%s'", err, first_error_buffer, detail, ERR_error_string(detail, error_buffer)); /* OpenSSL 0.9.6 and later has a function named ERRO_error_string_n() that takes the size of the buffer as a third argument, and we should possibly switch to using that one in the @@ -1149,9 +1160,6 @@ } } } - else - /* we have been connected fine, get out of the connect loop */ - break; interval.tv_sec = timeout_ms/1000; timeout_ms -= interval.tv_sec*1000;