Mercurial > hg > nginx
changeset 969:065b39794fff
ngx_ssl_get_server_conf()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 02 Jan 2007 23:37:25 +0000 |
parents | 1b60ecc8cdb7 |
children | 35f98a8e275f |
files | src/event/ngx_event_openssl.c src/event/ngx_event_openssl.h src/http/modules/ngx_http_proxy_module.c src/http/modules/ngx_http_ssl_module.c src/imap/ngx_imap_ssl_module.c |
diffstat | 5 files changed, 30 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/ngx_event_openssl.c Tue Jan 02 23:32:41 2007 +0000 +++ b/src/event/ngx_event_openssl.c Tue Jan 02 23:37:25 2007 +0000 @@ -84,7 +84,8 @@ }; -int ngx_connection_index; +int ngx_ssl_connection_index; +int ngx_ssl_server_conf_index; ngx_int_t @@ -101,19 +102,27 @@ ENGINE_load_builtin_engines(); #endif - ngx_connection_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL); + ngx_ssl_connection_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL); - if (ngx_connection_index == -1) { + if (ngx_ssl_connection_index == -1) { ngx_ssl_error(NGX_LOG_ALERT, log, 0, "SSL_get_ex_new_index() failed"); return NGX_ERROR; } + ngx_ssl_server_conf_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, + NULL); + if (ngx_ssl_server_conf_index == -1) { + ngx_ssl_error(NGX_LOG_ALERT, log, 0, + "SSL_CTX_get_ex_new_index() failed"); + return NGX_ERROR; + } + return NGX_OK; } ngx_int_t -ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols) +ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols, void *data) { ssl->ctx = SSL_CTX_new(SSLv23_method()); @@ -122,6 +131,12 @@ return NGX_ERROR; } + if (SSL_CTX_set_ex_data(ssl->ctx, ngx_ssl_server_conf_index, data) == 0) { + ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0, + "SSL_CTX_set_ex_data() failed"); + return NGX_ERROR; + } + /* client side options */ SSL_CTX_set_options(ssl->ctx, SSL_OP_MICROSOFT_SESS_ID_BUG); @@ -336,7 +351,7 @@ SSL_set_accept_state(sc->connection); } - if (SSL_set_ex_data(sc->connection, ngx_connection_index, c) == 0) { + if (SSL_set_ex_data(sc->connection, ngx_ssl_connection_index, c) == 0) { ngx_ssl_error(NGX_LOG_ALERT, c->log, 0, "SSL_set_ex_data() failed"); return NGX_ERROR; }
--- a/src/event/ngx_event_openssl.h Tue Jan 02 23:32:41 2007 +0000 +++ b/src/event/ngx_event_openssl.h Tue Jan 02 23:37:25 2007 +0000 @@ -63,7 +63,7 @@ ngx_int_t ngx_ssl_init(ngx_log_t *log); -ngx_int_t ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols); +ngx_int_t ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols, void *data); ngx_int_t ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert, ngx_str_t *key); ngx_int_t ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, @@ -75,7 +75,10 @@ ngx_int_t ngx_ssl_set_session(ngx_connection_t *c, ngx_ssl_session_t *session); #define ngx_ssl_get_session(c) SSL_get1_session(c->ssl->connection) #define ngx_ssl_free_session SSL_SESSION_free -#define ngx_ssl_get_connection(sc) SSL_get_ex_data(sc, ngx_connection_index) +#define ngx_ssl_get_connection(ssl_conn) \ + SSL_get_ex_data(ssl_conn, ngx_ssl_connection_index) +#define ngx_ssl_get_server_conf(ssl_ctx) \ + SSL_CTX_get_ex_data(ssl_ctx, ngx_ssl_server_conf_index) ngx_int_t ngx_ssl_get_protocol(ngx_connection_t *c, ngx_pool_t *pool, @@ -104,7 +107,8 @@ void ngx_ssl_cleanup_ctx(void *data); -extern int ngx_connection_index; +extern int ngx_ssl_connection_index; +extern int ngx_ssl_server_conf_index; #endif /* _NGX_EVENT_OPENSSL_H_INCLUDED_ */
--- a/src/http/modules/ngx_http_proxy_module.c Tue Jan 02 23:32:41 2007 +0000 +++ b/src/http/modules/ngx_http_proxy_module.c Tue Jan 02 23:37:25 2007 +0000 @@ -2130,7 +2130,7 @@ plcf->upstream.ssl->log = cf->log; if (ngx_ssl_create(plcf->upstream.ssl, - NGX_SSL_SSLv2|NGX_SSL_SSLv3|NGX_SSL_TLSv1) + NGX_SSL_SSLv2|NGX_SSL_SSLv3|NGX_SSL_TLSv1, NULL) != NGX_OK) { return NGX_CONF_ERROR;
--- a/src/http/modules/ngx_http_ssl_module.c Tue Jan 02 23:32:41 2007 +0000 +++ b/src/http/modules/ngx_http_ssl_module.c Tue Jan 02 23:37:25 2007 +0000 @@ -330,7 +330,7 @@ conf->ssl.log = cf->log; - if (ngx_ssl_create(&conf->ssl, conf->protocols) != NGX_OK) { + if (ngx_ssl_create(&conf->ssl, conf->protocols, conf) != NGX_OK) { return NGX_CONF_ERROR; }
--- a/src/imap/ngx_imap_ssl_module.c Tue Jan 02 23:32:41 2007 +0000 +++ b/src/imap/ngx_imap_ssl_module.c Tue Jan 02 23:37:25 2007 +0000 @@ -206,7 +206,7 @@ conf->ssl.log = cf->log; - if (ngx_ssl_create(&conf->ssl, conf->protocols) != NGX_OK) { + if (ngx_ssl_create(&conf->ssl, conf->protocols, NULL) != NGX_OK) { return NGX_CONF_ERROR; }