aboutsummaryrefslogtreecommitdiffstats
path: root/src/gnutls_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnutls_io.c')
-rw-r--r--src/gnutls_io.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gnutls_io.c b/src/gnutls_io.c
index 925517b..14e7cf6 100644
--- a/src/gnutls_io.c
+++ b/src/gnutls_io.c
@@ -353,10 +353,13 @@ static apr_status_t gnutls_io_input_getline(mgs_handle_t * ctxt,
353 return APR_SUCCESS; 353 return APR_SUCCESS;
354} 354}
355 355
356#define HANDSHAKE_MAX_TRIES 100
356static int gnutls_do_handshake(mgs_handle_t * ctxt) 357static int gnutls_do_handshake(mgs_handle_t * ctxt)
357{ 358{
358 int ret; 359 int ret;
359 int errcode; 360 int errcode;
361 int maxtries = HANDSHAKE_MAX_TRIES;
362
360 if (ctxt->status != 0) { 363 if (ctxt->status != 0) {
361 return -1; 364 return -1;
362 } 365 }
@@ -364,8 +367,24 @@ static int gnutls_do_handshake(mgs_handle_t * ctxt)
364tryagain: 367tryagain:
365 do { 368 do {
366 ret = gnutls_handshake(ctxt->session); 369 ret = gnutls_handshake(ctxt->session);
367 } while (ret == GNUTLS_E_AGAIN); 370 maxtries--;
368 371 } while (ret == GNUTLS_E_AGAIN && maxtries > 0);
372
373 if (maxtries < 1) {
374 ctxt->status = -1;
375#if USING_2_1_RECENT
376 ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, ctxt->c,
377 "GnuTLS: Handshake Failed. Hit Maximum Attempts");
378#else
379 ap_log_error(APLOG_MARK, APLOG_ERR, 0, ctxt->c->base_server,
380 "GnuTLS: Handshake Failed. Hit Maximum Attempts");
381#endif
382 gnutls_alert_send(ctxt->session, GNUTLS_AL_FATAL,
383 gnutls_error_to_alert(ret, NULL));
384 gnutls_deinit(ctxt->session);
385 return -1;
386 }
387
369 if (ret < 0) { 388 if (ret < 0) {
370 if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED 389 if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED
371 || ret == GNUTLS_E_FATAL_ALERT_RECEIVED) { 390 || ret == GNUTLS_E_FATAL_ALERT_RECEIVED) {