diff options
| author | Lars Magne Ingebrigtsen | 2014-11-26 23:11:57 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2014-11-26 23:11:57 +0100 |
| commit | fc4d2c7784184a01bdbf9d428fe22aed4039b159 (patch) | |
| tree | c882bdc2927b6c3aa162169de35d50a35e26b7fd /src/gnutls.c | |
| parent | ccae04f205db7cffa0f247a463272f6c5af77122 (diff) | |
| download | emacs-fc4d2c7784184a01bdbf9d428fe22aed4039b159.tar.gz emacs-fc4d2c7784184a01bdbf9d428fe22aed4039b159.zip | |
Only send SNI if the host name is not an IP address
* gnutls.c (gnutls_ip_address_p): New function.
(Fgnutls_boot): Only send SNI if the host name is not an IP address.
Diffstat (limited to 'src/gnutls.c')
| -rw-r--r-- | src/gnutls.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/gnutls.c b/src/gnutls.c index 5a4b39f789a..752df3c8edd 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -1095,6 +1095,18 @@ emacs_gnutls_global_init (void) | |||
| 1095 | return gnutls_make_error (ret); | 1095 | return gnutls_make_error (ret); |
| 1096 | } | 1096 | } |
| 1097 | 1097 | ||
| 1098 | static bool | ||
| 1099 | gnutls_ip_address_p (char *string) | ||
| 1100 | { | ||
| 1101 | char c; | ||
| 1102 | |||
| 1103 | while ((c = *string++) != 0) | ||
| 1104 | if (! ((c == '.' || c == ':' || (c >= '0' && c <= '9')))) | ||
| 1105 | return false; | ||
| 1106 | |||
| 1107 | return true; | ||
| 1108 | } | ||
| 1109 | |||
| 1098 | #if 0 | 1110 | #if 0 |
| 1099 | /* Deinitializes global GnuTLS state. | 1111 | /* Deinitializes global GnuTLS state. |
| 1100 | See also `gnutls-global-init'. */ | 1112 | See also `gnutls-global-init'. */ |
| @@ -1418,10 +1430,13 @@ one trustfile (usually a CA bundle). */) | |||
| 1418 | if (ret < GNUTLS_E_SUCCESS) | 1430 | if (ret < GNUTLS_E_SUCCESS) |
| 1419 | return gnutls_make_error (ret); | 1431 | return gnutls_make_error (ret); |
| 1420 | 1432 | ||
| 1421 | ret = fn_gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname, | 1433 | if (!gnutls_ip_address_p (c_hostname)) |
| 1422 | strlen(c_hostname)); | 1434 | { |
| 1423 | if (ret < GNUTLS_E_SUCCESS) | 1435 | ret = fn_gnutls_server_name_set (state, GNUTLS_NAME_DNS, c_hostname, |
| 1424 | return gnutls_make_error (ret); | 1436 | strlen (c_hostname)); |
| 1437 | if (ret < GNUTLS_E_SUCCESS) | ||
| 1438 | return gnutls_make_error (ret); | ||
| 1439 | } | ||
| 1425 | 1440 | ||
| 1426 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; | 1441 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; |
| 1427 | ret = emacs_gnutls_handshake (XPROCESS (proc)); | 1442 | ret = emacs_gnutls_handshake (XPROCESS (proc)); |