summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Kaduk <kaduk@mit.edu>2018-09-04 11:44:07 -0500
committerMatt Caswell <matt@openssl.org>2018-09-07 15:21:27 +0100
commit2c0267fdc99f8a06cb205f0faecc2ff06f0de8bf (patch)
tree277f57ad2313dc6187afea58816083dc38ff5723
parentcd3b53b8f85ad66336936073d822b3315e0ddd4f (diff)
Restore historical SSL_get_servername() behavior
Commit 1c4aa31d79821dee9be98e915159d52cc30d8403 modified the state machine to clean up stale ext.hostname values from SSL objects in the case when SNI was not negotiated for the current handshake. This is natural from the TLS perspective, since this information is an extension that the client offered but we ignored, and since we ignored it we do not need to keep it around for anything else. However, as documented in https://github.com/openssl/openssl/issues/7014 , there appear to be some deployed code that relies on retrieving such an ignored SNI value from the client, after the handshake has completed. Because the 1.1.1 release is on a stable branch and should preserve the published ABI, restore the historical behavior by retaining the ext.hostname value sent by the client, in the SSL structure, for subsequent retrieval. [extended tests] Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7115)
-rw-r--r--ssl/statem/extensions.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c
index 307e6b9d6f..cd4f078cf3 100644
--- a/ssl/statem/extensions.c
+++ b/ssl/statem/extensions.c
@@ -938,11 +938,8 @@ static int final_server_name(SSL *s, unsigned int context, int sent)
* was successful.
*/
if (s->server) {
- if (!sent) {
- /* Nothing from the client this handshake; cleanup stale value */
- OPENSSL_free(s->ext.hostname);
- s->ext.hostname = NULL;
- } else if (ret == SSL_TLSEXT_ERR_OK && (!s->hit || SSL_IS_TLS13(s))) {
+ /* TODO(OpenSSL1.2) revisit !sent case */
+ if (sent && ret == SSL_TLSEXT_ERR_OK && (!s->hit || SSL_IS_TLS13(s))) {
/* Only store the hostname in the session if we accepted it. */
OPENSSL_free(s->session->ext.hostname);
s->session->ext.hostname = OPENSSL_strdup(s->ext.hostname);