aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2016-03-05 17:04:23 +0100
committerLars Magne Ingebrigtsen2016-03-05 17:04:34 +0100
commit21b509d4449bd33045e019dbcc90f5283434c07e (patch)
tree644fc1aa00a61458b1cb05456bdeac0a90e885fa /src
parent76b97fb0f9674fb0d0a888bc3aefc79a03faab70 (diff)
downloademacs-21b509d4449bd33045e019dbcc90f5283434c07e.tar.gz
emacs-21b509d4449bd33045e019dbcc90f5283434c07e.zip
Allow making TLS negotiation blocking
* lisp/net/gnutls.el (gnutls-negotiate): Make negotiation blocking. * src/gnutls.c (Fgnutls_boot): Provide a new keyword, :complete-negotiation, to specify that we want complete negotiation even if the socket is non-blocking. (gnutls_try_handshake): Complete negotiation if given that keyword. * src/process.h (L): Added gnutls_complete_negotiation_p.
Diffstat (limited to 'src')
-rw-r--r--src/gnutls.c17
-rw-r--r--src/process.h1
2 files changed, 15 insertions, 3 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index 988c0104869..db22c924f0c 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -402,8 +402,12 @@ gnutls_try_handshake (struct Lisp_Process *proc)
402{ 402{
403 gnutls_session_t state = proc->gnutls_state; 403 gnutls_session_t state = proc->gnutls_state;
404 int ret; 404 int ret;
405 bool non_blocking = proc->is_non_blocking_client;
405 406
406 if (proc->is_non_blocking_client) 407 if (proc->gnutls_complete_negotiation_p)
408 non_blocking = false;
409
410 if (non_blocking)
407 proc->gnutls_p = true; 411 proc->gnutls_p = true;
408 412
409 do 413 do
@@ -412,8 +416,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
412 emacs_gnutls_handle_error (state, ret); 416 emacs_gnutls_handle_error (state, ret);
413 QUIT; 417 QUIT;
414 } 418 }
415 while (ret < 0 && gnutls_error_is_fatal (ret) == 0 419 while (ret < 0
416 && ! proc->is_non_blocking_client); 420 && gnutls_error_is_fatal (ret) == 0
421 && ! non_blocking);
417 422
418 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; 423 proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
419 424
@@ -1354,6 +1359,9 @@ t to do all checks. Currently it can contain `:trustfiles' and
1354:min-prime-bits is the minimum accepted number of bits the client will 1359:min-prime-bits is the minimum accepted number of bits the client will
1355accept in Diffie-Hellman key exchange. 1360accept in Diffie-Hellman key exchange.
1356 1361
1362:complete-negotiation, if non-nil, will make negotiation complete
1363before returning even on non-blocking sockets.
1364
1357The debug level will be set for this process AND globally for GnuTLS. 1365The debug level will be set for this process AND globally for GnuTLS.
1358So if you set it higher or lower at any point, it affects global 1366So if you set it higher or lower at any point, it affects global
1359debugging. 1367debugging.
@@ -1642,6 +1650,8 @@ one trustfile (usually a CA bundle). */)
1642 return gnutls_make_error (ret); 1650 return gnutls_make_error (ret);
1643 } 1651 }
1644 1652
1653 XPROCESS (proc)->gnutls_complete_negotiation_p =
1654 !NILP (Fplist_get (proplist, QCgnutls_complete_negotiation));
1645 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; 1655 GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET;
1646 ret = emacs_gnutls_handshake (XPROCESS (proc)); 1656 ret = emacs_gnutls_handshake (XPROCESS (proc));
1647 if (ret < GNUTLS_E_SUCCESS) 1657 if (ret < GNUTLS_E_SUCCESS)
@@ -1734,6 +1744,7 @@ syms_of_gnutls (void)
1734 DEFSYM (QCgnutls_bootprop_crlfiles, ":crlfiles"); 1744 DEFSYM (QCgnutls_bootprop_crlfiles, ":crlfiles");
1735 DEFSYM (QCgnutls_bootprop_min_prime_bits, ":min-prime-bits"); 1745 DEFSYM (QCgnutls_bootprop_min_prime_bits, ":min-prime-bits");
1736 DEFSYM (QCgnutls_bootprop_loglevel, ":loglevel"); 1746 DEFSYM (QCgnutls_bootprop_loglevel, ":loglevel");
1747 DEFSYM (QCgnutls_complete_negotiation, ":complete-negotiation");
1737 DEFSYM (QCgnutls_bootprop_verify_flags, ":verify-flags"); 1748 DEFSYM (QCgnutls_bootprop_verify_flags, ":verify-flags");
1738 DEFSYM (QCgnutls_bootprop_verify_error, ":verify-error"); 1749 DEFSYM (QCgnutls_bootprop_verify_error, ":verify-error");
1739 1750
diff --git a/src/process.h b/src/process.h
index 038d58b7370..95bd1b65363 100644
--- a/src/process.h
+++ b/src/process.h
@@ -193,6 +193,7 @@ struct Lisp_Process
193 int gnutls_log_level; 193 int gnutls_log_level;
194 int gnutls_handshakes_tried; 194 int gnutls_handshakes_tried;
195 bool_bf gnutls_p : 1; 195 bool_bf gnutls_p : 1;
196 bool_bf gnutls_complete_negotiation_p : 1;
196#endif 197#endif
197}; 198};
198 199