diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-07-15 16:35:51 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-07-15 16:35:51 +0000 |
commit | 1c3567ecc81a9f07f3c3d53912114bc5bd5daffa (patch) | |
tree | ba0b57b32bb1232af3fad0ff38375df9e498ec66 /src/http/modules | |
parent | 4aa888820d3f13a225ee6bdd596305ea3b4db6f4 (diff) | |
download | nginx-1c3567ecc81a9f07f3c3d53912114bc5bd5daffa.tar.gz nginx-1c3567ecc81a9f07f3c3d53912114bc5bd5daffa.zip |
nginx-0.0.7-2004-07-15-20:35:51 import
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_access_handler.c | 3 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssl_filter.c | 74 | ||||
-rw-r--r-- | src/http/modules/ngx_http_ssl_filter.h | 12 |
3 files changed, 50 insertions, 39 deletions
diff --git a/src/http/modules/ngx_http_access_handler.c b/src/http/modules/ngx_http_access_handler.c index 95e4f773b..a57526ef2 100644 --- a/src/http/modules/ngx_http_access_handler.c +++ b/src/http/modules/ngx_http_access_handler.c @@ -193,8 +193,11 @@ static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle) ngx_http_conf_ctx_t *ctx; ngx_http_core_main_conf_t *cmcf; +#if 0 ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index]; cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; +#endif + cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module); h = ngx_push_array(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers); if (h == NULL) { diff --git a/src/http/modules/ngx_http_ssl_filter.c b/src/http/modules/ngx_http_ssl_filter.c index 297f5c7b6..f64ef5417 100644 --- a/src/http/modules/ngx_http_ssl_filter.c +++ b/src/http/modules/ngx_http_ssl_filter.c @@ -3,52 +3,41 @@ #include <ngx_core.h> #include <ngx_http.h> +/* STUB */ +#define NGX_SSL_ERROR -11 + #define NGX_DEFLAUT_CERTIFICATE "cert.pem" #define NGX_DEFLAUT_CERTIFICATE_KEY "cert.pem" -typedef struct { - ngx_flag_t enable; - ngx_str_t certificate; - ngx_str_t certificate_key; - - SSL_CTX *ssl_ctx; -} ngx_http_ssl_srv_conf_t; - - -typedef struct { - SSL *ssl; -} ngx_http_ssl_ctx_t; - - static ngx_int_t ngx_http_ssl_create_ssl(ngx_http_request_t *r); static void ngx_http_ssl_error(ngx_uint_t level, ngx_log_t *log, int err, char *fmt, ...); 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); -static ngx_int_t ngx_http_ssl_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_ssl_init_process(ngx_cycle_t *cycle); static ngx_command_t ngx_http_charset_filter_commands[] = { - { ngx_string("ssl_"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, + { ngx_string("ssl"), + NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, NGX_HTTP_SRV_CONF_OFFSET, offsetof(ngx_http_ssl_srv_conf_t, enable), NULL }, { ngx_string("ssl_certificate"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_str_slot, NGX_HTTP_SRV_CONF_OFFSET, offsetof(ngx_http_ssl_srv_conf_t, certificate), NULL }, { ngx_string("ssl_certificate_key"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_str_slot, NGX_HTTP_SRV_CONF_OFFSET, offsetof(ngx_http_ssl_srv_conf_t, certificate_key), @@ -75,10 +64,10 @@ static ngx_http_module_t ngx_http_ssl_filter_module_ctx = { ngx_module_t ngx_http_ssl_filter_module = { NGX_MODULE, &ngx_http_ssl_filter_module_ctx, /* module context */ - NULL, /* module directives */ + ngx_http_charset_filter_commands, /* module directives */ NGX_HTTP_MODULE, /* module type */ - ngx_http_ssl_filter_init, /* init module */ - NULL /* init process */ + NULL, /* init module */ + ngx_http_ssl_init_process /* init process */ }; @@ -86,7 +75,6 @@ ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t size) { int n; SSL *ssl; - ngx_http_ssl_ctx_t *ctx; ngx_http_log_ctx_t *log_ctx; if (r->connection->ssl == NULL) { @@ -334,18 +322,16 @@ static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, ngx_conf_merge_value(conf->enable, prev->enable, 0); + if (conf->enable == 0) { + return NGX_CONF_OK; + } + ngx_conf_merge_str_value(conf->certificate, prev->certificate, NGX_DEFLAUT_CERTIFICATE); ngx_conf_merge_str_value(conf->certificate_key, prev->certificate_key, NGX_DEFLAUT_CERTIFICATE_KEY); - /* STUB: where to move ??? */ - SSL_library_init(); - SSL_load_error_strings(); - - /* TODO: inherit ssl_ctx */ - /* TODO: configure methods */ conf->ssl_ctx = SSL_CTX_new(SSLv23_server_method()); @@ -358,14 +344,16 @@ static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, if (SSL_CTX_use_certificate_file(conf->ssl_ctx, conf->certificate.data, SSL_FILETYPE_PEM) == 0) { ngx_http_ssl_error(NGX_LOG_EMERG, cf->log, 0, - "SSL_CTX_use_certificate_file() failed"); + "SSL_CTX_use_certificate_file(\"%s\") failed", + conf->certificate.data); return NGX_CONF_ERROR; } if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx, conf->certificate_key.data, SSL_FILETYPE_PEM) == 0) { ngx_http_ssl_error(NGX_LOG_EMERG, cf->log, 0, - "SSL_CTX_use_PrivateKey_file() failed"); + "SSL_CTX_use_PrivateKey_file(\"%s\") failed", + conf->certificate_key.data); return NGX_CONF_ERROR; } @@ -373,15 +361,27 @@ static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, } -static ngx_int_t ngx_http_ssl_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_ssl_init_process(ngx_cycle_t *cycle) { -#if 0 - ngx_http_next_header_filter = ngx_http_top_header_filter; - ngx_http_top_header_filter = ngx_http_ssl_header_filter; + ngx_uint_t i; + ngx_http_ssl_srv_conf_t *sscf; + ngx_http_core_srv_conf_t **cscfp; + ngx_http_core_main_conf_t *cmcf; + + cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module); + + cscfp = cmcf->servers.elts; - ngx_http_next_body_filter = ngx_http_top_body_filter; - ngx_http_top_body_filter = ngx_http_ssl_body_filter; + for (i = 0; i < cmcf->servers.nelts; i++) { + sscf = cscfp[i]->ctx->srv_conf[ngx_http_ssl_filter_module.ctx_index]; + + if (sscf->enable) { + cscfp[i]->recv = ngx_ssl_recv; +#if 0 + cscfp[i]->send_chain = ngx_ssl_send_chain; #endif + } + } return NGX_OK; } diff --git a/src/http/modules/ngx_http_ssl_filter.h b/src/http/modules/ngx_http_ssl_filter.h index a96a26781..a42ee9135 100644 --- a/src/http/modules/ngx_http_ssl_filter.h +++ b/src/http/modules/ngx_http_ssl_filter.h @@ -7,8 +7,13 @@ #include <ngx_http.h> -#define NGX_SSL_ERROR -10 -#define NGX_SSL_HTTP_ERROR -11 +typedef struct { + ngx_flag_t enable; + ngx_str_t certificate; + ngx_str_t certificate_key; + + ngx_ssl_ctx_t *ssl_ctx; +} ngx_http_ssl_srv_conf_t; ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t size); @@ -19,4 +24,7 @@ ngx_chain_t *ngx_http_ssl_write(ngx_connection_t *c, ngx_chain_t *in, void ngx_http_ssl_close_connection(SSL *ssl, ngx_log_t *log); +extern ngx_module_t ngx_http_ssl_filter_module; + + #endif /* _NGX_HTTP_SSL_FILTER_H_INCLUDED_ */ |