]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Split host to connected_host and sni_host
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 1 Nov 2017 10:58:46 +0000 (12:58 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 1 Nov 2017 14:02:20 +0000 (16:02 +0200)
Using the same variable for both was causing confusion.

src/lib-ssl-iostream/iostream-openssl-context.c
src/lib-ssl-iostream/iostream-openssl.c
src/lib-ssl-iostream/iostream-openssl.h

index f39a51d5e299a4fc54deb6e0df2bae94fc367e44..ef8c70615f20b30bdf982c36a530a9cf8e67843e 100644 (file)
@@ -301,8 +301,8 @@ static int ssl_servername_callback(SSL *ssl, int *al ATTR_UNUSED,
        ssl_io = SSL_get_ex_data(ssl, dovecot_ssl_extdata_index);
        host = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
        if (SSL_get_servername_type(ssl) != -1) {
-               i_free(ssl_io->host);
-               ssl_io->host = i_strdup(host);
+               i_free(ssl_io->sni_host);
+               ssl_io->sni_host = i_strdup(host);
        } else if (ssl_io->verbose) {
                i_debug("SSL_get_servername() failed");
        }
index e6f5480ec736ff01a41da10736a9e7f21a14d4f7..058d0fe6ab2deb7afc2aed048f67bef58c4d8f8d 100644 (file)
@@ -262,7 +262,7 @@ openssl_iostream_create(struct ssl_iostream_context *ctx, const char *host,
        ssl_io->bio_ext = bio_ext;
        ssl_io->plain_input = *input;
        ssl_io->plain_output = *output;
-       ssl_io->host = i_strdup(host);
+       ssl_io->connected_host = i_strdup(host);
        ssl_io->log_prefix = host == NULL ? i_strdup("") :
                i_strdup_printf("%s: ", host);
        /* bio_int will be freed by SSL_free() */
@@ -303,7 +303,8 @@ static void openssl_iostream_free(struct ssl_iostream *ssl_io)
        SSL_free(ssl_io->ssl);
        i_free(ssl_io->plain_stream_errstr);
        i_free(ssl_io->last_error);
-       i_free(ssl_io->host);
+       i_free(ssl_io->connected_host);
+       i_free(ssl_io->sni_host);
        i_free(ssl_io->log_prefix);
        i_free(ssl_io);
 }
@@ -701,7 +702,7 @@ openssl_iostream_get_peer_name(struct ssl_iostream *ssl_io)
 
 static const char *openssl_iostream_get_server_name(struct ssl_iostream *ssl_io)
 {
-       return ssl_io->host;
+       return ssl_io->sni_host;
 }
 
 static const char *
index 7e874f59b83a5a0a87721ab1671eaac81fa65814..a358edc3c7072ee15d954383b1d6875e9c2c0ca2 100644 (file)
@@ -33,7 +33,10 @@ struct ssl_iostream {
        struct istream *ssl_input;
        struct ostream *ssl_output;
 
-       char *host;
+       /* SSL clients: host where we connected to */
+       char *connected_host;
+       /* SSL servers: host requested by the client via SNI */
+       char *sni_host;
        char *last_error;
        char *log_prefix;
        char *plain_stream_errstr;