Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_ssl_module.c @ 612:182bfe05e2c3
release-0.3.27 tag
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 08 Feb 2006 15:33:12 +0000 |
parents | 3f8a2132b93d |
children | e60fe4cf1d4e |
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 |
611 | 12 typedef u_char *(*ngx_ssl_variable_handler_pt)(ngx_connection_t *); |
13 | |
14 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 #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
|
16 #define NGX_DEFLAUT_CERTIFICATE_KEY "cert.pem" |
547 | 17 #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
|
18 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
611 | 20 static ngx_int_t ngx_http_ssl_variable(ngx_http_request_t *r, |
21 ngx_http_variable_value_t *v, uintptr_t data); | |
22 | |
23 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
|
24 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
|
25 static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, |
501 | 26 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
|
27 |
563 | 28 #if !defined (SSL_OP_CIPHER_SERVER_PREFERENCE) |
29 | |
30 static char *ngx_http_ssl_nosupported(ngx_conf_t *cf, ngx_command_t *cmd, | |
31 void *conf); | |
32 | |
33 static char ngx_http_ssl_openssl097[] = "OpenSSL 0.9.7 and higher"; | |
34 | |
35 #endif | |
36 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
547 | 38 static ngx_conf_bitmask_t ngx_http_ssl_protocols[] = { |
39 { ngx_string("SSLv2"), NGX_SSL_SSLv2 }, | |
40 { ngx_string("SSLv3"), NGX_SSL_SSLv3 }, | |
41 { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, | |
42 { ngx_null_string, 0 } | |
43 }; | |
44 | |
45 | |
563 | 46 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
47 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
|
48 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
49 { ngx_string("ssl"), |
599 | 50 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
|
51 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
|
52 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
|
53 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
|
54 NULL }, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 { ngx_string("ssl_certificate"), |
599 | 57 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
|
58 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
|
59 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
|
60 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
|
61 NULL }, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
62 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
63 { ngx_string("ssl_certificate_key"), |
599 | 64 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
|
65 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
|
66 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
|
67 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
|
68 NULL }, |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
547 | 70 { ngx_string("ssl_protocols"), |
563 | 71 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_1MORE, |
547 | 72 ngx_conf_set_bitmask_slot, |
73 NGX_HTTP_SRV_CONF_OFFSET, | |
74 offsetof(ngx_http_ssl_srv_conf_t, protocols), | |
75 &ngx_http_ssl_protocols }, | |
76 | |
479 | 77 { ngx_string("ssl_ciphers"), |
563 | 78 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
479 | 79 ngx_conf_set_str_slot, |
80 NGX_HTTP_SRV_CONF_OFFSET, | |
81 offsetof(ngx_http_ssl_srv_conf_t, ciphers), | |
82 NULL }, | |
83 | |
547 | 84 { ngx_string("ssl_prefer_server_ciphers"), |
85 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, | |
563 | 86 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE |
547 | 87 ngx_conf_set_flag_slot, |
88 NGX_HTTP_SRV_CONF_OFFSET, | |
89 offsetof(ngx_http_ssl_srv_conf_t, prefer_server_ciphers), | |
90 NULL }, | |
563 | 91 #else |
92 ngx_http_ssl_nosupported, 0, 0, ngx_http_ssl_openssl097 }, | |
93 #endif | |
547 | 94 |
573 | 95 { ngx_string("ssl_session_timeout"), |
96 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
97 ngx_conf_set_sec_slot, | |
98 NGX_HTTP_SRV_CONF_OFFSET, | |
99 offsetof(ngx_http_ssl_srv_conf_t, session_timeout), | |
100 NULL }, | |
101 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 ngx_null_command |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 }; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
106 static ngx_http_module_t ngx_http_ssl_module_ctx = { |
611 | 107 ngx_http_ssl_add_variables, /* preconfiguration */ |
509 | 108 NULL, /* postconfiguration */ |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 |
541 | 110 NULL, /* create main configuration */ |
111 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
|
112 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 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
|
114 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
|
115 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 NULL, /* create location configuration */ |
485 | 117 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
|
118 }; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
119 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
121 ngx_module_t ngx_http_ssl_module = { |
509 | 122 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
|
123 &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
|
124 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
|
125 NGX_HTTP_MODULE, /* module type */ |
541 | 126 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
|
127 NULL, /* init module */ |
541 | 128 NULL, /* init process */ |
129 NULL, /* init thread */ | |
130 NULL, /* exit thread */ | |
131 NULL, /* exit process */ | |
132 NULL, /* exit master */ | |
133 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
|
134 }; |
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 |
611 | 137 static ngx_http_variable_t ngx_http_ssl_vars[] = { |
138 | |
139 { ngx_string("ssl_protocol"), ngx_http_ssl_variable, | |
140 (uintptr_t) ngx_ssl_get_protocol, NGX_HTTP_VAR_CHANGABLE, 0 }, | |
141 | |
142 { ngx_string("ssl_cipher"), ngx_http_ssl_variable, | |
143 (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGABLE, 0 }, | |
144 | |
145 { ngx_null_string, NULL, 0, 0, 0 } | |
146 }; | |
147 | |
148 | |
543 | 149 static u_char ngx_http_session_id_ctx[] = "HTTP"; |
150 | |
151 | |
611 | 152 static ngx_int_t |
153 ngx_http_ssl_variable(ngx_http_request_t *r, | |
154 ngx_http_variable_value_t *v, uintptr_t data) | |
155 { | |
156 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; | |
157 | |
158 size_t len; | |
159 u_char *name; | |
160 | |
161 if (r->connection->ssl) { | |
162 | |
163 name = handler(r->connection); | |
164 | |
165 for (len = 0; name[len]; len++) { /* void */ } | |
166 | |
167 v->len = len; | |
168 v->valid = 1; | |
169 v->no_cachable = 0; | |
170 v->not_found = 0; | |
171 v->data = name; | |
172 | |
173 return NGX_OK; | |
174 } | |
175 | |
176 v->not_found = 1; | |
177 | |
178 return NGX_OK; | |
179 } | |
180 | |
181 | |
182 static ngx_int_t | |
183 ngx_http_ssl_add_variables(ngx_conf_t *cf) | |
184 { | |
185 ngx_http_variable_t *var, *v; | |
186 | |
187 for (v = ngx_http_ssl_vars; v->name.len; v++) { | |
188 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
189 if (var == NULL) { | |
190 return NGX_ERROR; | |
191 } | |
192 | |
193 var->handler = v->handler; | |
194 var->data = v->data; | |
195 } | |
196 | |
197 return NGX_OK; | |
198 } | |
199 | |
200 | |
501 | 201 static void * |
202 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
|
203 { |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 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
|
205 |
501 | 206 scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t)); |
207 if (scf == NULL) { | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 return NGX_CONF_ERROR; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 } |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 |
479 | 211 /* |
212 * set by ngx_pcalloc(): | |
213 * | |
547 | 214 * scf->protocols = 0; |
215 | |
479 | 216 * scf->certificate.len = 0; |
217 * scf->certificate.data = NULL; | |
218 * scf->certificate_key.len = 0; | |
219 * scf->certificate_key.data = NULL; | |
220 * scf->ciphers.len = 0; | |
221 * scf->ciphers.data = NULL; | |
222 */ | |
223 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 scf->enable = NGX_CONF_UNSET; |
573 | 225 scf->session_timeout = NGX_CONF_UNSET; |
547 | 226 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
|
227 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 return scf; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 } |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
501 | 232 static char * |
233 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
|
234 { |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 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
|
236 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
|
237 |
563 | 238 ngx_pool_cleanup_t *cln; |
239 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 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
|
241 |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
242 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
|
243 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
|
244 } |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
392
diff
changeset
|
245 |
573 | 246 ngx_conf_merge_value(conf->session_timeout, |
247 prev->session_timeout, 300); | |
248 | |
547 | 249 ngx_conf_merge_value(conf->prefer_server_ciphers, |
250 prev->prefer_server_ciphers, 0); | |
251 | |
252 ngx_conf_merge_bitmask_value(conf->protocols, prev->protocols, | |
253 (NGX_CONF_BITMASK_SET | |
254 |NGX_SSL_SSLv2|NGX_SSL_SSLv3|NGX_SSL_TLSv1)); | |
255 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 ngx_conf_merge_str_value(conf->certificate, prev->certificate, |
547 | 257 NGX_DEFLAUT_CERTIFICATE); |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 ngx_conf_merge_str_value(conf->certificate_key, prev->certificate_key, |
547 | 260 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
|
261 |
547 | 262 ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFLAUT_CIPHERS); |
479 | 263 |
264 | |
547 | 265 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
|
266 |
547 | 267 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
|
268 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
|
269 } |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
270 |
563 | 271 cln = ngx_pool_cleanup_add(cf->pool, 0); |
272 if (cln == NULL) { | |
509 | 273 return NGX_CONF_ERROR; |
274 } | |
275 | |
563 | 276 cln->handler = ngx_ssl_cleanup_ctx; |
277 cln->data = &conf->ssl; | |
278 | |
279 if (ngx_ssl_certificate(cf, &conf->ssl, &conf->certificate, | |
280 &conf->certificate_key) != NGX_OK) | |
529 | 281 { |
386
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
282 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
|
283 } |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
284 |
547 | 285 if (SSL_CTX_set_cipher_list(conf->ssl.ctx, |
563 | 286 (const char *) conf->ciphers.data) |
287 == 0) | |
529 | 288 { |
395
f8f0f1834266
nginx-0.0.7-2004-07-16-21:11:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
394
diff
changeset
|
289 ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, |
547 | 290 "SSL_CTX_set_cipher_list(\"%V\") failed", |
291 &conf->ciphers); | |
292 } | |
293 | |
563 | 294 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE |
295 | |
547 | 296 if (conf->prefer_server_ciphers) { |
297 SSL_CTX_set_options(conf->ssl.ctx, SSL_OP_CIPHER_SERVER_PREFERENCE); | |
298 } | |
299 | |
563 | 300 #endif |
301 | |
547 | 302 /* a temporary 512-bit RSA key is required for export versions of MSIE */ |
303 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
|
304 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
|
305 } |
fa72605e7089
nginx-0.0.7-2004-07-12-01:03:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
385
diff
changeset
|
306 |
547 | 307 SSL_CTX_set_session_cache_mode(conf->ssl.ctx, SSL_SESS_CACHE_SERVER); |
543 | 308 |
547 | 309 SSL_CTX_set_session_id_context(conf->ssl.ctx, ngx_http_session_id_ctx, |
543 | 310 sizeof(ngx_http_session_id_ctx) - 1); |
541 | 311 |
573 | 312 SSL_CTX_set_timeout(conf->ssl.ctx, conf->session_timeout); |
313 | |
383
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
314 return NGX_CONF_OK; |
c05876036128
nginx-0.0.7-2004-07-08-19:17:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
315 } |
563 | 316 |
317 | |
318 #if !defined (SSL_OP_CIPHER_SERVER_PREFERENCE) | |
319 | |
320 static char * | |
321 ngx_http_ssl_nosupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
322 { | |
323 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
324 "\"%V\" directive is available only in %s,", | |
325 &cmd->name, cmd->post); | |
326 | |
327 return NGX_CONF_ERROR; | |
328 } | |
329 | |
330 #endif |