[PATCH] SNI: add $ssl_servername variable.
Piotr Sikora
piotr at cloudflare.com
Tue May 21 23:12:41 UTC 2013
# HG changeset patch
# User Piotr Sikora <piotr at cloudflare.com>
# Date 1369177341 25200
# Node ID 4d617cb445673c8e3c43d75c240a7d401b394ee8
# Parent 8646199ded31a725bea599aeafc581f9c969872d
SNI: add $ssl_servername variable.
Signed-off-by: Piotr Sikora <piotr at cloudflare.com>
diff -r 8646199ded31 -r 4d617cb44567 src/event/ngx_event_openssl.c
--- a/src/event/ngx_event_openssl.c Tue May 21 16:02:10 2013 -0700
+++ b/src/event/ngx_event_openssl.c Tue May 21 16:02:21 2013 -0700
@@ -2221,6 +2221,21 @@
ngx_int_t
+ngx_ssl_get_servername(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
+{
+#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
+ if (c->ssl->servername) {
+ *s = *c->ssl->servername;
+ return NGX_OK;
+ }
+#endif
+
+ s->len = 0;
+ return NGX_OK;
+}
+
+
+ngx_int_t
ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
{
int len;
diff -r 8646199ded31 -r 4d617cb44567 src/event/ngx_event_openssl.h
--- a/src/event/ngx_event_openssl.h Tue May 21 16:02:10 2013 -0700
+++ b/src/event/ngx_event_openssl.h Tue May 21 16:02:21 2013 -0700
@@ -146,6 +146,8 @@
ngx_str_t *s);
ngx_int_t ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool,
ngx_str_t *s);
+ngx_int_t ngx_ssl_get_servername(ngx_connection_t *c, ngx_pool_t *pool,
+ ngx_str_t *s);
ngx_int_t ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool,
ngx_str_t *s);
ngx_int_t ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool,
diff -r 8646199ded31 -r 4d617cb44567 src/http/modules/ngx_http_ssl_module.c
--- a/src/http/modules/ngx_http_ssl_module.c Tue May 21 16:02:10 2013 -0700
+++ b/src/http/modules/ngx_http_ssl_module.c Tue May 21 16:02:21 2013 -0700
@@ -238,6 +238,9 @@
{ ngx_string("ssl_cipher"), NULL, ngx_http_ssl_static_variable,
(uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGEABLE, 0 },
+ { ngx_string("ssl_servername"), NULL, ngx_http_ssl_variable,
+ (uintptr_t) ngx_ssl_get_servername, NGX_HTTP_VAR_CHANGEABLE, 0 },
+
{ ngx_string("ssl_session_id"), NULL, ngx_http_ssl_variable,
(uintptr_t) ngx_ssl_get_session_id, NGX_HTTP_VAR_CHANGEABLE, 0 },
More information about the nginx-devel
mailing list