118 |
static int allow_any_purpose= FALSE; |
static int allow_any_purpose= FALSE; |
119 |
|
|
120 |
/* Error handling */ |
/* Error handling */ |
121 |
static int handle_connection_error(int, ssl_connection *, char *); |
static int handle_connection_error(int, ssl_connection *, char *, int); |
122 |
static void handle_ssl_error(char *); |
static void handle_ssl_error(char *); |
123 |
#define SSLERROR ERR_error_string(ERR_get_error(),NULL) |
#define SSLERROR ERR_error_string(ERR_get_error(),NULL) |
124 |
|
|
236 |
|
|
237 |
} |
} |
238 |
|
|
239 |
if (!handle_connection_error(ssl_error, ssl, "embed_ssl_socket()")) { |
if (!handle_connection_error(ssl_error, ssl, "embed_ssl_socket()", SSL_TIMEOUT)) { |
240 |
|
|
241 |
goto sslerror; |
goto sslerror; |
242 |
|
|
243 |
} |
} |
244 |
|
|
245 |
|
if (!BIO_should_retry(ssl->socket_bio)) { |
246 |
|
|
247 |
|
goto sslerror; |
248 |
|
|
249 |
|
} |
250 |
|
|
251 |
|
|
252 |
} |
} |
253 |
|
|
254 |
ssl->cipher= (char *) SSL_get_cipher(ssl->handler); |
ssl->cipher= (char *) SSL_get_cipher(ssl->handler); |
1071 |
} |
} |
1072 |
|
|
1073 |
if (!handle_connection_error(ssl_error, ssl, |
if (!handle_connection_error(ssl_error, ssl, |
1074 |
"embed_accepted_ssl_socket()")) { |
"embed_accepted_ssl_socket()", SSL_TIMEOUT)) { |
1075 |
|
|
1076 |
goto sslerror; |
goto sslerror; |
1077 |
|
|
1078 |
} |
} |
1079 |
|
|
1080 |
|
if (!BIO_should_retry(ssl->socket_bio)) { |
1081 |
|
|
1082 |
|
goto sslerror; |
1083 |
|
|
1084 |
|
} |
1085 |
|
|
1086 |
} |
} |
1087 |
|
|
1088 |
ssl->cipher= (char *) SSL_get_cipher(ssl->handler); |
ssl->cipher= (char *) SSL_get_cipher(ssl->handler); |
1879 |
* @return TRUE if non fatal, FALSE if non fatal and retry |
* @return TRUE if non fatal, FALSE if non fatal and retry |
1880 |
*/ |
*/ |
1881 |
static int handle_connection_error(int code, ssl_connection *ssl, |
static int handle_connection_error(int code, ssl_connection *ssl, |
1882 |
char *operation) { |
char *operation, int timeout) { |
1883 |
|
|
1884 |
int ssl_error= 0; |
int ssl_error= 0; |
1885 |
|
|
1886 |
switch ((ssl_error= SSL_get_error(ssl->handler, code))) { |
switch ((ssl_error= SSL_get_error(ssl->handler, code))) { |
1887 |
|
|
1888 |
case SSL_ERROR_WANT_READ: |
case SSL_ERROR_WANT_READ: |
1889 |
|
if (can_read(ssl->socket, timeout)) |
1890 |
|
return TRUE; |
1891 |
|
else |
1892 |
|
log("%s: %s: Openssl read timeout error!\n", prog, operation); |
1893 |
|
return FALSE; |
1894 |
|
|
1895 |
case SSL_ERROR_WANT_WRITE: |
case SSL_ERROR_WANT_WRITE: |
1896 |
return TRUE; |
if (can_read(ssl->socket, timeout)) |
1897 |
|
return TRUE; |
1898 |
|
else |
1899 |
|
log("%s: %s: Openssl write timeout error!\n", prog, operation); |
1900 |
|
return FALSE; |
1901 |
|
|
1902 |
case SSL_ERROR_SYSCALL: |
case SSL_ERROR_SYSCALL: |
1903 |
log("%s: %s: Openssl syscall error: %s!\n", prog, operation, |
log("%s: %s: Openssl syscall error: %s!\n", prog, operation, |