Mercurial > hg > nginx
diff src/http/modules/ngx_http_ssl_module.c @ 611:3f8a2132b93d release-0.3.27
nginx-0.3.27-RELEASE import
*) Change: the "variables_hash_max_size" and
"variables_hash_bucket_size" directives.
*) Feature: the $body_bytes_sent variable can be used not only in the
"log_format" directive.
*) Feature: the $ssl_protocol and $ssl_cipher variables.
*) Feature: the cache line size detection for widespread CPUs at start
time.
*) Feature: now the "accept_mutex" directive is supported using
fcntl(2) on platforms different from i386, amd64, sparc64, and ppc.
*) Feature: the "lock_file" directive and the --with-lock-path=PATH
autoconfiguration directive.
*) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive
then the requests with the body was not transferred.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 08 Feb 2006 15:33:12 +0000 |
parents | 869b6444d234 |
children | e60fe4cf1d4e |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_ssl_module.c Fri Feb 03 12:58:48 2006 +0000 +++ b/src/http/modules/ngx_http_ssl_module.c Wed Feb 08 15:33:12 2006 +0000 @@ -9,11 +9,18 @@ #include <ngx_http.h> +typedef u_char *(*ngx_ssl_variable_handler_pt)(ngx_connection_t *); + + #define NGX_DEFLAUT_CERTIFICATE "cert.pem" #define NGX_DEFLAUT_CERTIFICATE_KEY "cert.pem" #define NGX_DEFLAUT_CIPHERS "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP" +static ngx_int_t ngx_http_ssl_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); + +static ngx_int_t ngx_http_ssl_add_variables(ngx_conf_t *cf); static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf); static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child); @@ -97,7 +104,7 @@ static ngx_http_module_t ngx_http_ssl_module_ctx = { - NULL, /* preconfiguration */ + ngx_http_ssl_add_variables, /* preconfiguration */ NULL, /* postconfiguration */ NULL, /* create main configuration */ @@ -127,9 +134,70 @@ }; +static ngx_http_variable_t ngx_http_ssl_vars[] = { + + { ngx_string("ssl_protocol"), ngx_http_ssl_variable, + (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGABLE, 0 }, + + { ngx_string("ssl_cipher"), ngx_http_ssl_variable, + (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGABLE, 0 }, + + { ngx_null_string, NULL, 0, 0, 0 } +}; + + static u_char ngx_http_session_id_ctx[] = "HTTP"; +static ngx_int_t +ngx_http_ssl_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; + + size_t len; + u_char *name; + + if (r->connection->ssl) { + + name = handler(r->connection); + + for (len = 0; name[len]; len++) { /* void */ } + + v->len = len; + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + v->data = name; + + return NGX_OK; + } + + v->not_found = 1; + + return NGX_OK; +} + + +static ngx_int_t +ngx_http_ssl_add_variables(ngx_conf_t *cf) +{ + ngx_http_variable_t *var, *v; + + for (v = ngx_http_ssl_vars; v->name.len; v++) { + var = ngx_http_add_variable(cf, &v->name, v->flags); + if (var == NULL) { + return NGX_ERROR; + } + + var->handler = v->handler; + var->data = v->data; + } + + return NGX_OK; +} + + static void * ngx_http_ssl_create_srv_conf(ngx_conf_t *cf) {