annotate src/http/modules/ngx_http_ssl_module.c @ 320:95183808f549 NGINX_0_6_4

nginx 0.6.4 *) Security: the "msie_refresh" directive allowed XSS. Thanks to Maxim Boguk. *) Change: the "proxy_store" and "fastcgi_store" directives were changed. *) Feature: the "proxy_store_access" and "fastcgi_store_access" directives. *) Bugfix: nginx did not work on Solaris/sparc64 if it was built by Sun Studio. Thanks to Andrei Nigmatulin. *) Workaround: for Sun Studio 12. Thanks to Jiang Hong.
author Igor Sysoev <http://sysoev.ru>
date Tue, 17 Jul 2007 00:00:00 +0400
parents 55328d69b335
children 10cc350ed8a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_http.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
11
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
12 typedef ngx_int_t (*ngx_ssl_variable_handler_pt)(ngx_connection_t *c,
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
13 ngx_pool_t *pool, ngx_str_t *s);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
14
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
15
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
16 #define NGX_DEFLAUT_CERTIFICATE "cert.pem"
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
17 #define NGX_DEFLAUT_CERTIFICATE_KEY "cert.pem"
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
18 #define NGX_DEFLAUT_CIPHERS "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP"
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
19
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
20
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
21 static ngx_int_t ngx_http_ssl_static_variable(ngx_http_request_t *r,
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
22 ngx_http_variable_value_t *v, uintptr_t data);
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
23 static ngx_int_t ngx_http_ssl_variable(ngx_http_request_t *r,
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
24 ngx_http_variable_value_t *v, uintptr_t data);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
25
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
26 static ngx_int_t ngx_http_ssl_add_variables(ngx_conf_t *cf);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
27 static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28 static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
29 void *parent, void *child);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
30
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
31 static char *ngx_http_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
32 void *conf);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
33
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
34 #if !defined (SSL_OP_CIPHER_SERVER_PREFERENCE)
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
35
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
36 static char *ngx_http_ssl_nosupported(ngx_conf_t *cf, ngx_command_t *cmd,
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
37 void *conf);
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
38
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
39 static char ngx_http_ssl_openssl097[] = "OpenSSL 0.9.7 and higher";
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
40
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
41 #endif
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
42
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
43
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
44 static ngx_conf_bitmask_t ngx_http_ssl_protocols[] = {
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
45 { ngx_string("SSLv2"), NGX_SSL_SSLv2 },
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
46 { ngx_string("SSLv3"), NGX_SSL_SSLv3 },
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
47 { ngx_string("TLSv1"), NGX_SSL_TLSv1 },
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
48 { ngx_null_string, 0 }
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
49 };
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
50
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
51
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
52 static ngx_command_t ngx_http_ssl_commands[] = {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
54 { ngx_string("ssl"),
148
ea622d8acb38 nginx 0.3.21
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
55 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56 ngx_conf_set_flag_slot,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57 NGX_HTTP_SRV_CONF_OFFSET,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
58 offsetof(ngx_http_ssl_srv_conf_t, enable),
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59 NULL },
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
61 { ngx_string("ssl_certificate"),
148
ea622d8acb38 nginx 0.3.21
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
62 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
63 ngx_conf_set_str_slot,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
64 NGX_HTTP_SRV_CONF_OFFSET,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
65 offsetof(ngx_http_ssl_srv_conf_t, certificate),
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
66 NULL },
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
67
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
68 { ngx_string("ssl_certificate_key"),
148
ea622d8acb38 nginx 0.3.21
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
69 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
70 ngx_conf_set_str_slot,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71 NGX_HTTP_SRV_CONF_OFFSET,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
72 offsetof(ngx_http_ssl_srv_conf_t, certificate_key),
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
73 NULL },
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
74
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
75 { ngx_string("ssl_protocols"),
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
76 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
77 ngx_conf_set_bitmask_slot,
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
78 NGX_HTTP_SRV_CONF_OFFSET,
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
79 offsetof(ngx_http_ssl_srv_conf_t, protocols),
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
80 &ngx_http_ssl_protocols },
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
81
28
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
82 { ngx_string("ssl_ciphers"),
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
83 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
28
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
84 ngx_conf_set_str_slot,
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
85 NGX_HTTP_SRV_CONF_OFFSET,
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
86 offsetof(ngx_http_ssl_srv_conf_t, ciphers),
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
87 NULL },
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
88
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
89 { ngx_string("ssl_verify_client"),
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 196
diff changeset
90 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
91 ngx_conf_set_flag_slot,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
92 NGX_HTTP_SRV_CONF_OFFSET,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
93 offsetof(ngx_http_ssl_srv_conf_t, verify),
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
94 NULL },
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
95
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
96 { ngx_string("ssl_verify_depth"),
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
97 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
98 ngx_conf_set_num_slot,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
99 NGX_HTTP_SRV_CONF_OFFSET,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
100 offsetof(ngx_http_ssl_srv_conf_t, verify_depth),
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
101 NULL },
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
102
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
103 { ngx_string("ssl_client_certificate"),
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
104 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
105 ngx_conf_set_str_slot,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
106 NGX_HTTP_SRV_CONF_OFFSET,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
107 offsetof(ngx_http_ssl_srv_conf_t, client_certificate),
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
108 NULL },
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
109
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
110 { ngx_string("ssl_prefer_server_ciphers"),
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
111 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
112 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
113 ngx_conf_set_flag_slot,
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
114 NGX_HTTP_SRV_CONF_OFFSET,
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
115 offsetof(ngx_http_ssl_srv_conf_t, prefer_server_ciphers),
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
116 NULL },
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
117 #else
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
118 ngx_http_ssl_nosupported, 0, 0, ngx_http_ssl_openssl097 },
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
119 #endif
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
120
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
121 { ngx_string("ssl_session_cache"),
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
122 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE12,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
123 ngx_http_ssl_session_cache,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
124 NGX_HTTP_SRV_CONF_OFFSET,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
125 0,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
126 NULL },
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
127
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
128 { ngx_string("ssl_session_timeout"),
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
129 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
130 ngx_conf_set_sec_slot,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
131 NGX_HTTP_SRV_CONF_OFFSET,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
132 offsetof(ngx_http_ssl_srv_conf_t, session_timeout),
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
133 NULL },
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
134
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
135 ngx_null_command
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
136 };
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
137
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
138
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
139 static ngx_http_module_t ngx_http_ssl_module_ctx = {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
140 ngx_http_ssl_add_variables, /* preconfiguration */
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
141 NULL, /* postconfiguration */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
142
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
143 NULL, /* create main configuration */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
144 NULL, /* init main configuration */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
145
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
146 ngx_http_ssl_create_srv_conf, /* create server configuration */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
147 ngx_http_ssl_merge_srv_conf, /* merge server configuration */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
148
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
149 NULL, /* create location configuration */
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
150 NULL /* merge location configuration */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
151 };
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
152
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
153
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
154 ngx_module_t ngx_http_ssl_module = {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
155 NGX_MODULE_V1,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
156 &ngx_http_ssl_module_ctx, /* module context */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
157 ngx_http_ssl_commands, /* module directives */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
158 NGX_HTTP_MODULE, /* module type */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
159 NULL, /* init master */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
160 NULL, /* init module */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
161 NULL, /* init process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
162 NULL, /* init thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
163 NULL, /* exit thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
164 NULL, /* exit process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
165 NULL, /* exit master */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 78
diff changeset
166 NGX_MODULE_V1_PADDING
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
167 };
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
168
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
169
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
170 static ngx_http_variable_t ngx_http_ssl_vars[] = {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
171
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
172 { ngx_string("ssl_protocol"), NULL, ngx_http_ssl_static_variable,
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
173 (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGABLE, 0 },
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
174
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
175 { ngx_string("ssl_cipher"), NULL, ngx_http_ssl_static_variable,
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
176 (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGABLE, 0 },
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
177
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
178 { ngx_string("ssl_client_s_dn"), NULL, ngx_http_ssl_variable,
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
179 (uintptr_t) ngx_ssl_get_subject_dn, NGX_HTTP_VAR_CHANGABLE, 0 },
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
180
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
181 { ngx_string("ssl_client_i_dn"), NULL, ngx_http_ssl_variable,
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
182 (uintptr_t) ngx_ssl_get_issuer_dn, NGX_HTTP_VAR_CHANGABLE, 0 },
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
183
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
184 { ngx_string("ssl_client_serial"), NULL, ngx_http_ssl_variable,
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
185 (uintptr_t) ngx_ssl_get_serial_number, NGX_HTTP_VAR_CHANGABLE, 0 },
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
186
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
187 { ngx_null_string, NULL, NULL, 0, 0, 0 }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
188 };
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
189
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
190
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
191 static ngx_str_t ngx_http_ssl_sess_id_ctx = ngx_string("HTTP");
92
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
192
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
193
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
194 static ngx_int_t
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
195 ngx_http_ssl_static_variable(ngx_http_request_t *r,
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
196 ngx_http_variable_value_t *v, uintptr_t data)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
197 {
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
198 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
199
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
200 size_t len;
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
201 ngx_str_t s;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
202
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
203 if (r->connection->ssl) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
204
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
205 (void) handler(r->connection, NULL, &s);
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
206
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
207 v->data = s.data;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
208
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
209 for (len = 0; v->data[len]; len++) { /* void */ }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
210
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
211 v->len = len;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
212 v->valid = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
213 v->no_cachable = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
214 v->not_found = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
215
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
216 return NGX_OK;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
217 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
218
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
219 v->not_found = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
220
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
221 return NGX_OK;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
222 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
223
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
224
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
225 static ngx_int_t
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
226 ngx_http_ssl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
227 uintptr_t data)
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
228 {
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
229 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data;
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
230
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
231 ngx_str_t s;
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
232
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
233 if (r->connection->ssl) {
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
234
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
235 if (handler(r->connection, r->pool, &s) != NGX_OK) {
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
236 return NGX_ERROR;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
237 }
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
238
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
239 v->len = s.len;
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
240 v->data = s.data;
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 306
diff changeset
241
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
242 if (v->len) {
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
243 v->valid = 1;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
244 v->no_cachable = 0;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
245 v->not_found = 0;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
246
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
247 return NGX_OK;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
248 }
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
249 }
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
250
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
251 v->not_found = 1;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
252
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
253 return NGX_OK;
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
254 }
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
255
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
256
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
257 static ngx_int_t
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
258 ngx_http_ssl_add_variables(ngx_conf_t *cf)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
259 {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
260 ngx_http_variable_t *var, *v;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
261
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
262 for (v = ngx_http_ssl_vars; v->name.len; v++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
263 var = ngx_http_add_variable(cf, &v->name, v->flags);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
264 if (var == NULL) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
265 return NGX_ERROR;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
266 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
267
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
268 var->get_handler = v->get_handler;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
269 var->data = v->data;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
270 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
271
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
272 return NGX_OK;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
273 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
274
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 148
diff changeset
275
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
276 static void *
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
277 ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
278 {
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
279 ngx_http_ssl_srv_conf_t *sscf;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
280
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
281 sscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t));
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
282 if (sscf == NULL) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
283 return NGX_CONF_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
284 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
285
28
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
286 /*
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
287 * set by ngx_pcalloc():
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
288 *
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
289 * sscf->protocols = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
290 * sscf->certificate.len = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
291 * sscf->certificate.data = NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
292 * sscf->certificate_key.len = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
293 * sscf->certificate_key.data = NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
294 * sscf->client_certificate.len = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
295 * sscf->client_certificate.data = NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
296 * sscf->ciphers.len = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
297 * sscf->ciphers.data = NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
298 * sscf->shm_zone = NULL;
28
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
299 */
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
300
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
301 sscf->enable = NGX_CONF_UNSET;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
302 sscf->verify = NGX_CONF_UNSET;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
303 sscf->verify_depth = NGX_CONF_UNSET;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
304 sscf->prefer_server_ciphers = NGX_CONF_UNSET;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
305 sscf->builtin_session_cache = NGX_CONF_UNSET;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
306 sscf->session_timeout = NGX_CONF_UNSET;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
307
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
308 return sscf;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
309 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
310
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
311
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
312 static char *
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
313 ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
314 {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
315 ngx_http_ssl_srv_conf_t *prev = parent;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
316 ngx_http_ssl_srv_conf_t *conf = child;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
317
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
318 ngx_pool_cleanup_t *cln;
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
319
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
320 ngx_conf_merge_value(conf->enable, prev->enable, 0);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
321
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
322 if (conf->enable == 0) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
323 return NGX_CONF_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
324 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
325
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
326 ngx_conf_merge_value(conf->session_timeout,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
327 prev->session_timeout, 300);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
328
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
329 ngx_conf_merge_value(conf->prefer_server_ciphers,
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
330 prev->prefer_server_ciphers, 0);
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
331
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
332 ngx_conf_merge_bitmask_value(conf->protocols, prev->protocols,
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
333 (NGX_CONF_BITMASK_SET
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
334 |NGX_SSL_SSLv2|NGX_SSL_SSLv3|NGX_SSL_TLSv1));
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
335
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
336 ngx_conf_merge_value(conf->verify, prev->verify, 0);
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
337 ngx_conf_merge_value(conf->verify_depth, prev->verify_depth, 1);
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
338
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
339 ngx_conf_merge_str_value(conf->certificate, prev->certificate,
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
340 NGX_DEFLAUT_CERTIFICATE);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
341
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
342 ngx_conf_merge_str_value(conf->certificate_key, prev->certificate_key,
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
343 NGX_DEFLAUT_CERTIFICATE_KEY);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
344
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
345 ngx_conf_merge_str_value(conf->client_certificate, prev->client_certificate,
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
346 "");
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
347
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
348 ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFLAUT_CIPHERS);
28
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
349
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
350
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
351 conf->ssl.log = cf->log;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
352
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
353 if (ngx_ssl_create(&conf->ssl, conf->protocols, conf) != NGX_OK) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
354 return NGX_CONF_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
355 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
356
306
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
357 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
358
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
359 if (SSL_CTX_set_tlsext_servername_callback(conf->ssl.ctx,
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
360 ngx_http_ssl_servername)
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
361 == 0)
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
362 {
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
363 ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
364 "SSL_CTX_set_tlsext_servername_callback() failed");
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
365 return NGX_CONF_ERROR;
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
366 }
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
367
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
368 #endif
55328d69b335 nginx 0.5.23
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
369
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
370 cln = ngx_pool_cleanup_add(cf->pool, 0);
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
371 if (cln == NULL) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
372 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
373 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
374
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
375 cln->handler = ngx_ssl_cleanup_ctx;
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
376 cln->data = &conf->ssl;
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
377
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
378 if (ngx_ssl_certificate(cf, &conf->ssl, &conf->certificate,
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
379 &conf->certificate_key)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
380 != NGX_OK)
78
9db7e0b5b27f nginx 0.1.39
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
381 {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
382 return NGX_CONF_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
383 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
384
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
385 if (SSL_CTX_set_cipher_list(conf->ssl.ctx,
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
386 (const char *) conf->ciphers.data)
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
387 == 0)
78
9db7e0b5b27f nginx 0.1.39
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
388 {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
389 ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
390 "SSL_CTX_set_cipher_list(\"%V\") failed",
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
391 &conf->ciphers);
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
392 }
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
393
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
394 if (conf->verify) {
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
395 if (ngx_ssl_client_certificate(cf, &conf->ssl,
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
396 &conf->client_certificate,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
397 conf->verify_depth)
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
398 != NGX_OK)
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
399 {
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 218
diff changeset
400 return NGX_CONF_ERROR;
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
401 }
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
402 }
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
403
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
404 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
405
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
406 if (conf->prefer_server_ciphers) {
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
407 SSL_CTX_set_options(conf->ssl.ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
408 }
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
409
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
410 #endif
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
411
96
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
412 /* a temporary 512-bit RSA key is required for export versions of MSIE */
ca4f70b3ccc6 nginx 0.2.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
413 if (ngx_ssl_generate_rsa512_key(&conf->ssl) != NGX_OK) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
414 return NGX_CONF_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
415 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
416
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
417 ngx_conf_merge_value(conf->builtin_session_cache,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
418 prev->builtin_session_cache,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
419 NGX_SSL_DFLT_BUILTIN_SCACHE);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
420
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
421 if (conf->shm_zone == NULL) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
422 conf->shm_zone = prev->shm_zone;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
423 }
92
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
424
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
425 if (ngx_ssl_session_cache(&conf->ssl, &ngx_http_ssl_sess_id_ctx,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
426 conf->builtin_session_cache,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
427 conf->shm_zone, conf->session_timeout)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
428 != NGX_OK)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
429 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
430 return NGX_CONF_ERROR;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
431 }
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
432
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
433 return NGX_CONF_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
434 }
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
435
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
436
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
437 static char *
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
438 ngx_http_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
439 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
440 ngx_http_ssl_srv_conf_t *sscf = conf;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
441
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
442 size_t len;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
443 ngx_str_t *value, name, size;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
444 ngx_int_t n;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
445 ngx_uint_t i, j;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
446
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
447 value = cf->args->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
448
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
449 for (i = 1; i < cf->args->nelts; i++) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
450
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
451 if (ngx_strcmp(value[i].data, "builtin") == 0) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
452 sscf->builtin_session_cache = NGX_SSL_DFLT_BUILTIN_SCACHE;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
453 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
454 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
455
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
456 if (value[i].len > sizeof("builtin:") - 1
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
457 && ngx_strncmp(value[i].data, "builtin:", sizeof("builtin:") - 1)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
458 == 0)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
459 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
460 n = ngx_atoi(value[i].data + sizeof("builtin:") - 1,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
461 value[i].len - (sizeof("builtin:") - 1));
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
462
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
463 if (n == NGX_ERROR) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
464 goto invalid;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
465 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
466
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
467 sscf->builtin_session_cache = n;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
468
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
469 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
470 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
471
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
472 if (value[i].len > sizeof("shared:") - 1
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
473 && ngx_strncmp(value[i].data, "shared:", sizeof("shared:") - 1)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
474 == 0)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
475 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
476 len = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
477
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
478 for (j = sizeof("shared:") - 1; j < value[i].len; j++) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
479 if (value[i].data[j] == ':') {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
480 break;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
481 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
482
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
483 len++;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
484 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
485
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
486 if (len == 0) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
487 goto invalid;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
488 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
489
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
490 name.len = len;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
491 name.data = value[i].data + sizeof("shared:") - 1;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
492
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
493 size.len = value[i].len - j - 1;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
494 size.data = name.data + len + 1;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
495
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
496 n = ngx_parse_size(&size);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
497
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
498 if (n == NGX_ERROR) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
499 goto invalid;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
500 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
501
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
502 if (n < (ngx_int_t) (8 * ngx_pagesize)) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
503 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
504 "session cache \"%V\" is too small",
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
505 &value[i]);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
506
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
507 return NGX_CONF_ERROR;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
508 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
509
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
510 sscf->shm_zone = ngx_shared_memory_add(cf, &name, n,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
511 &ngx_http_ssl_module);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
512 if (sscf->shm_zone == NULL) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
513 return NGX_CONF_ERROR;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
514 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
515
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
516 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
517 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
518
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
519 goto invalid;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
520 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
521
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
522 if (sscf->shm_zone && sscf->builtin_session_cache == NGX_CONF_UNSET) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
523 sscf->builtin_session_cache = NGX_SSL_NO_BUILTIN_SCACHE;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
524 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
525
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
526 return NGX_CONF_OK;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
527
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
528 invalid:
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
529
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
530 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
531 "invalid session cache \"%V\"", &value[i]);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
532
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
533 return NGX_CONF_ERROR;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
534 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
535
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
536
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
537 #if !defined (SSL_OP_CIPHER_SERVER_PREFERENCE)
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
538
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
539 static char *
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
540 ngx_http_ssl_nosupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
541 {
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
542 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
543 "\"%V\" directive is available only in %s,",
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
544 &cmd->name, cmd->post);
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
545
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
546 return NGX_CONF_ERROR;
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
547 }
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
548
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 96
diff changeset
549 #endif