[OpenWrt-Devel] [PATCH 3/3] ustream-ssl: Add support for Server Name Indication

Christoph Ziebuhr chris at codefrickler.de
Mon Dec 1 08:51:34 EST 2014


Signed-off-by: Christoph Ziebuhr <chris at codefrickler.de>
---
 ustream-openssl.h  | 5 +++++
 ustream-polarssl.h | 5 +++++
 ustream-ssl.c      | 4 ++++
 ustream-ssl.h      | 1 +
 4 files changed, 15 insertions(+)

diff --git a/ustream-openssl.h b/ustream-openssl.h
index ef786f2..afff22b 100644
--- a/ustream-openssl.h
+++ b/ustream-openssl.h
@@ -39,4 +39,9 @@ static inline void __ustream_ssl_update_peer_cn(struct ustream_ssl *us)
 {
 }
 
+static inline void __ustream_ssl_set_server_name(struct ustream_ssl *us)
+{
+	SSL_set_tlsext_host_name(us->ssl, us->server_name);
+}
+
 #endif
diff --git a/ustream-polarssl.h b/ustream-polarssl.h
index 527c14a..dfc287d 100644
--- a/ustream-polarssl.h
+++ b/ustream-polarssl.h
@@ -50,6 +50,11 @@ static inline char *__ustream_ssl_strerror(int error, char *buffer, int len)
 	return buffer;
 }
 
+static inline void __ustream_ssl_set_server_name(struct ustream_ssl *us)
+{
+	ssl_set_hostname(us->ssl, us->server_name);
+}
+
 void __ustream_ssl_update_peer_cn(struct ustream_ssl *us);
 void __ustream_ssl_session_free(void *ssl);
 void *__ustream_ssl_session_new(struct ustream_ssl_ctx *ctx);
diff --git a/ustream-ssl.c b/ustream-ssl.c
index cf8cb84..dd0faf9 100644
--- a/ustream-ssl.c
+++ b/ustream-ssl.c
@@ -186,6 +186,10 @@ static int _ustream_ssl_init(struct ustream_ssl *us, struct ustream *conn, struc
 	conn->next = &us->stream;
 	ustream_set_io(ctx, us->ssl, conn);
 	ustream_ssl_stream_init(us);
+
+	if (us->server_name)
+		__ustream_ssl_set_server_name(us);
+
 	ustream_ssl_check_conn(us);
 
 	return 0;
diff --git a/ustream-ssl.h b/ustream-ssl.h
index b4317af..0c55344 100644
--- a/ustream-ssl.h
+++ b/ustream-ssl.h
@@ -34,6 +34,7 @@ struct ustream_ssl {
 	void *ssl;
 
 	char *peer_cn;
+	char *server_name;
 
 	int error;
 	bool connected;
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list