Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_ssl_module.c @ 809:da9c1521319d
AUTH PLAIN LOGIN CRAM-MD5
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 24 Oct 2006 18:38:31 +0000 |
parents | cec32b3753ac |
children | 065b39794fff |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
5 |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
573 | 11 |
671 | 12 typedef ngx_int_t (*ngx_ssl_variable_handler_pt)(ngx_connection_t *c, |
13 ngx_pool_t *pool, ngx_str_t *s); | |
611 | 14 |
15 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 #define NGX_DEFLAUT_CERTIFICATE "cert.pem" |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 #define NGX_DEFLAUT_CERTIFICATE_KEY "cert.pem" |
547 | 18 #define NGX_DEFLAUT_CIPHERS "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP" |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 |
671 | 21 static ngx_int_t ngx_http_ssl_static_variable(ngx_http_request_t *r, |
611 | 22 ngx_http_variable_value_t *v, uintptr_t data); |
671 | 23 static ngx_int_t ngx_http_ssl_variable(ngx_http_request_t *r, |
647 | 24 ngx_http_variable_value_t *v, uintptr_t data); |
611 | 25 |
26 static ngx_int_t ngx_http_ssl_add_variables(ngx_conf_t *cf); | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf); |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, |
501 | 29 void *parent, void *child); |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
563 | 31 #if !defined (SSL_OP_CIPHER_SERVER_PREFERENCE) |
32 | |
33 static char *ngx_http_ssl_nosupported(ngx_conf_t *cf, ngx_command_t *cmd, | |
34 void *conf); | |
35 | |
36 static char ngx_http_ssl_openssl097[] = "OpenSSL 0.9.7 and higher"; | |
37 | |
38 #endif | |
39 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 |
547 | 41 static ngx_conf_bitmask_t ngx_http_ssl_protocols[] = { |
42 { ngx_string("SSLv2"), NGX_SSL_SSLv2 }, | |
43 { ngx_string("SSLv3"), NGX_SSL_SSLv3 }, | |
44 { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, | |
45 { ngx_null_string, 0 } | |
46 }; | |
47 | |
48 | |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
49 static ngx_command_t ngx_http_ssl_commands[] = { |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
51 { ngx_string("ssl"), |
599 | 52 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 ngx_conf_set_flag_slot, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 NGX_HTTP_SRV_CONF_OFFSET, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 offsetof(ngx_http_ssl_srv_conf_t, enable), |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 NULL }, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 { ngx_string("ssl_certificate"), |
599 | 59 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 ngx_conf_set_str_slot, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 NGX_HTTP_SRV_CONF_OFFSET, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
62 offsetof(ngx_http_ssl_srv_conf_t, certificate), |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
63 NULL }, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
64 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 { ngx_string("ssl_certificate_key"), |
599 | 66 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 ngx_conf_set_str_slot, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 NGX_HTTP_SRV_CONF_OFFSET, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 offsetof(ngx_http_ssl_srv_conf_t, certificate_key), |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 NULL }, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 |
547 | 72 { ngx_string("ssl_protocols"), |
563 | 73 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_1MORE, |
547 | 74 ngx_conf_set_bitmask_slot, |
75 NGX_HTTP_SRV_CONF_OFFSET, | |
76 offsetof(ngx_http_ssl_srv_conf_t, protocols), | |
77 &ngx_http_ssl_protocols }, | |
78 | |
479 | 79 { ngx_string("ssl_ciphers"), |
563 | 80 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
479 | 81 ngx_conf_set_str_slot, |
82 NGX_HTTP_SRV_CONF_OFFSET, | |
83 offsetof(ngx_http_ssl_srv_conf_t, ciphers), | |
84 NULL }, | |
85 | |
647 | 86 { ngx_string("ssl_verify_client"), |
667 | 87 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, |
647 | 88 ngx_conf_set_flag_slot, |
89 NGX_HTTP_SRV_CONF_OFFSET, | |
90 offsetof(ngx_http_ssl_srv_conf_t, verify), | |
91 NULL }, | |
92 | |
93 { ngx_string("ssl_verify_depth"), | |
94 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_1MORE, | |
95 ngx_conf_set_num_slot, | |
96 NGX_HTTP_SRV_CONF_OFFSET, | |
97 offsetof(ngx_http_ssl_srv_conf_t, verify_depth), | |
98 NULL }, | |
99 | |
100 { ngx_string("ssl_client_certificate"), | |
101 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
102 ngx_conf_set_str_slot, | |
103 NGX_HTTP_SRV_CONF_OFFSET, | |
104 offsetof(ngx_http_ssl_srv_conf_t, client_certificate), | |
105 NULL }, | |
106 | |
547 | 107 { ngx_string("ssl_prefer_server_ciphers"), |
108 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, | |
563 | 109 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE |
547 | 110 ngx_conf_set_flag_slot, |
111 NGX_HTTP_SRV_CONF_OFFSET, | |
112 offsetof(ngx_http_ssl_srv_conf_t, prefer_server_ciphers), | |
113 NULL }, | |
563 | 114 #else |
115 ngx_http_ssl_nosupported, 0, 0, ngx_http_ssl_openssl097 }, | |
116 #endif | |
547 | 117 |
573 | 118 { ngx_string("ssl_session_timeout"), |
119 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
120 ngx_conf_set_sec_slot, | |
121 NGX_HTTP_SRV_CONF_OFFSET, | |
122 offsetof(ngx_http_ssl_srv_conf_t, session_timeout), | |
123 NULL }, | |
124 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 ngx_null_command |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 }; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
129 static ngx_http_module_t ngx_http_ssl_module_ctx = { |
611 | 130 ngx_http_ssl_add_variables, /* preconfiguration */ |
509 | 131 NULL, /* postconfiguration */ |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 |
541 | 133 NULL, /* create main configuration */ |
134 NULL, /* init main configuration */ | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 ngx_http_ssl_create_srv_conf, /* create server configuration */ |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 ngx_http_ssl_merge_srv_conf, /* merge server configuration */ |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 NULL, /* create location configuration */ |
485 | 140 NULL /* merge location configuration */ |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 }; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
144 ngx_module_t ngx_http_ssl_module = { |
509 | 145 NGX_MODULE_V1, |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
146 &ngx_http_ssl_module_ctx, /* module context */ |
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
147 ngx_http_ssl_commands, /* module directives */ |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 NGX_HTTP_MODULE, /* module type */ |
541 | 149 NULL, /* init master */ |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
150 NULL, /* init module */ |
541 | 151 NULL, /* init process */ |
152 NULL, /* init thread */ | |
153 NULL, /* exit thread */ | |
154 NULL, /* exit process */ | |
155 NULL, /* exit master */ | |
156 NGX_MODULE_V1_PADDING | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 }; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 |
611 | 160 static ngx_http_variable_t ngx_http_ssl_vars[] = { |
161 | |
671 | 162 { ngx_string("ssl_protocol"), NULL, ngx_http_ssl_static_variable, |
611 | 163 (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGABLE, 0 }, |
164 | |
671 | 165 { ngx_string("ssl_cipher"), NULL, ngx_http_ssl_static_variable, |
611 | 166 (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGABLE, 0 }, |
167 | |
671 | 168 { ngx_string("ssl_client_s_dn"), NULL, ngx_http_ssl_variable, |
169 (uintptr_t) ngx_ssl_get_subject_dn, NGX_HTTP_VAR_CHANGABLE, 0 }, | |
647 | 170 |
671 | 171 { ngx_string("ssl_client_i_dn"), NULL, ngx_http_ssl_variable, |
172 (uintptr_t) ngx_ssl_get_issuer_dn, NGX_HTTP_VAR_CHANGABLE, 0 }, | |
173 | |
174 { ngx_string("ssl_client_serial"), NULL, ngx_http_ssl_variable, | |
175 (uintptr_t) ngx_ssl_get_serial_number, NGX_HTTP_VAR_CHANGABLE, 0 }, | |
647 | 176 |
637 | 177 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
611 | 178 }; |
179 | |
180 | |
543 | 181 static u_char ngx_http_session_id_ctx[] = "HTTP"; |
182 | |
183 | |
611 | 184 static ngx_int_t |
671 | 185 ngx_http_ssl_static_variable(ngx_http_request_t *r, |
611 | 186 ngx_http_variable_value_t *v, uintptr_t data) |
187 { | |
671 | 188 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; |
611 | 189 |
671 | 190 size_t len; |
611 | 191 |
192 if (r->connection->ssl) { | |
193 | |
671 | 194 (void) handler(r->connection, NULL, (ngx_str_t *) v); |
611 | 195 |
671 | 196 for (len = 0; v->data[len]; len++) { /* void */ } |
611 | 197 |
198 v->len = len; | |
199 v->valid = 1; | |
200 v->no_cachable = 0; | |
201 v->not_found = 0; | |
202 | |
203 return NGX_OK; | |
204 } | |
205 | |
206 v->not_found = 1; | |
207 | |
208 return NGX_OK; | |
209 } | |
210 | |
211 | |
212 static ngx_int_t | |
671 | 213 ngx_http_ssl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
647 | 214 uintptr_t data) |
215 { | |
671 | 216 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; |
647 | 217 |
218 if (r->connection->ssl) { | |
671 | 219 if (handler(r->connection, r->pool, (ngx_str_t *) v) != NGX_OK) { |
647 | 220 return NGX_ERROR; |
221 } | |
222 | |
223 if (v->len) { | |
224 v->valid = 1; | |
225 v->no_cachable = 0; | |
226 v->not_found = 0; | |
227 | |
228 return NGX_OK; | |
229 } | |
230 } | |
231 | |
232 v->not_found = 1; | |
233 | |
234 return NGX_OK; | |
235 } | |
236 | |
237 | |
238 static ngx_int_t | |
611 | 239 ngx_http_ssl_add_variables(ngx_conf_t *cf) |
240 { | |
241 ngx_http_variable_t *var, *v; | |
242 | |
243 for (v = ngx_http_ssl_vars; v->name.len; v++) { | |
244 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
245 if (var == NULL) { | |
246 return NGX_ERROR; | |
247 } | |
248 | |
637 | 249 var->get_handler = v->get_handler; |
611 | 250 var->data = v->data; |
251 } | |
252 | |
253 return NGX_OK; | |
254 } | |
255 | |
256 | |
501 | 257 static void * |
258 ngx_http_ssl_create_srv_conf(ngx_conf_t *cf) | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 { |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 ngx_http_ssl_srv_conf_t *scf; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 |
501 | 262 scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t)); |
263 if (scf == NULL) { | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
264 return NGX_CONF_ERROR; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
265 } |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
266 |
479 | 267 /* |
268 * set by ngx_pcalloc(): | |
269 * | |
547 | 270 * scf->protocols = 0; |
271 | |
479 | 272 * scf->certificate.len = 0; |
273 * scf->certificate.data = NULL; | |
274 * scf->certificate_key.len = 0; | |
275 * scf->certificate_key.data = NULL; | |
647 | 276 * scf->client_certificate.len = 0; |
277 * scf->client_certificate.data = NULL; | |
479 | 278 * scf->ciphers.len = 0; |
279 * scf->ciphers.data = NULL; | |
280 */ | |
281 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
282 scf->enable = NGX_CONF_UNSET; |
573 | 283 scf->session_timeout = NGX_CONF_UNSET; |
647 | 284 scf->verify = NGX_CONF_UNSET; |
285 scf->verify_depth = NGX_CONF_UNSET; | |
547 | 286 scf->prefer_server_ciphers = NGX_CONF_UNSET; |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
287 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 return scf; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 } |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
290 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
291 |
501 | 292 static char * |
293 ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 { |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 ngx_http_ssl_srv_conf_t *prev = parent; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
296 ngx_http_ssl_srv_conf_t *conf = child; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 |
563 | 298 ngx_pool_cleanup_t *cln; |
299 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
300 ngx_conf_merge_value(conf->enable, prev->enable, 0); |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
301 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
302 if (conf->enable == 0) { |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
303 return NGX_CONF_OK; |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
304 } |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
305 |
573 | 306 ngx_conf_merge_value(conf->session_timeout, |
307 prev->session_timeout, 300); | |
308 | |
547 | 309 ngx_conf_merge_value(conf->prefer_server_ciphers, |
310 prev->prefer_server_ciphers, 0); | |
311 | |
312 ngx_conf_merge_bitmask_value(conf->protocols, prev->protocols, | |
313 (NGX_CONF_BITMASK_SET | |
314 |NGX_SSL_SSLv2|NGX_SSL_SSLv3|NGX_SSL_TLSv1)); | |
315 | |
647 | 316 ngx_conf_merge_value(conf->verify, prev->verify, 0); |
317 ngx_conf_merge_value(conf->verify_depth, prev->verify_depth, 1); | |
318 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
319 ngx_conf_merge_str_value(conf->certificate, prev->certificate, |
547 | 320 NGX_DEFLAUT_CERTIFICATE); |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
321 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
322 ngx_conf_merge_str_value(conf->certificate_key, prev->certificate_key, |
547 | 323 NGX_DEFLAUT_CERTIFICATE_KEY); |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
324 |
647 | 325 ngx_conf_merge_str_value(conf->client_certificate, prev->client_certificate, |
326 ""); | |
327 | |
547 | 328 ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFLAUT_CIPHERS); |
479 | 329 |
330 | |
547 | 331 conf->ssl.log = cf->log; |
386
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
332 |
547 | 333 if (ngx_ssl_create(&conf->ssl, conf->protocols) != NGX_OK) { |
386
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
334 return NGX_CONF_ERROR; |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
335 } |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
336 |
563 | 337 cln = ngx_pool_cleanup_add(cf->pool, 0); |
338 if (cln == NULL) { | |
509 | 339 return NGX_CONF_ERROR; |
340 } | |
341 | |
563 | 342 cln->handler = ngx_ssl_cleanup_ctx; |
343 cln->data = &conf->ssl; | |
344 | |
345 if (ngx_ssl_certificate(cf, &conf->ssl, &conf->certificate, | |
346 &conf->certificate_key) != NGX_OK) | |
529 | 347 { |
386
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
348 return NGX_CONF_ERROR; |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
349 } |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
350 |
547 | 351 if (SSL_CTX_set_cipher_list(conf->ssl.ctx, |
563 | 352 (const char *) conf->ciphers.data) |
353 == 0) | |
529 | 354 { |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
355 ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, |
547 | 356 "SSL_CTX_set_cipher_list(\"%V\") failed", |
357 &conf->ciphers); | |
358 } | |
359 | |
647 | 360 if (conf->verify) { |
671 | 361 if (ngx_ssl_client_certificate(cf, &conf->ssl, |
362 &conf->client_certificate, conf->verify_depth) | |
363 != NGX_OK) | |
364 { | |
365 return NGX_CONF_ERROR; | |
647 | 366 } |
367 } | |
368 | |
563 | 369 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE |
370 | |
547 | 371 if (conf->prefer_server_ciphers) { |
372 SSL_CTX_set_options(conf->ssl.ctx, SSL_OP_CIPHER_SERVER_PREFERENCE); | |
373 } | |
374 | |
563 | 375 #endif |
376 | |
547 | 377 /* a temporary 512-bit RSA key is required for export versions of MSIE */ |
378 if (ngx_ssl_generate_rsa512_key(&conf->ssl) != NGX_OK) { | |
386
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
379 return NGX_CONF_ERROR; |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
380 } |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
381 |
547 | 382 SSL_CTX_set_session_cache_mode(conf->ssl.ctx, SSL_SESS_CACHE_SERVER); |
543 | 383 |
547 | 384 SSL_CTX_set_session_id_context(conf->ssl.ctx, ngx_http_session_id_ctx, |
543 | 385 sizeof(ngx_http_session_id_ctx) - 1); |
541 | 386 |
573 | 387 SSL_CTX_set_timeout(conf->ssl.ctx, conf->session_timeout); |
388 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
389 return NGX_CONF_OK; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
390 } |
563 | 391 |
392 | |
393 #if !defined (SSL_OP_CIPHER_SERVER_PREFERENCE) | |
394 | |
395 static char * | |
396 ngx_http_ssl_nosupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
397 { | |
398 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
399 "\"%V\" directive is available only in %s,", | |
400 &cmd->name, cmd->post); | |
401 | |
402 return NGX_CONF_ERROR; | |
403 } | |
404 | |
405 #endif |