| 1 | # HG changeset patch
|
|---|
| 2 | # User Maxim Dounin <mdounin@mdounin.ru>
|
|---|
| 3 | # Date 1321640105 -10800
|
|---|
| 4 | # Node ID 4cb602eb317f6e8e669af7cb808f814056015020
|
|---|
| 5 | # Parent dec8d0f5d34bb7c2a2e1ac8d8347d113ebb47d5a
|
|---|
| 6 | Fixed segfault on ssl servers without cert with SNI (ticket #54).
|
|---|
| 7 |
|
|---|
| 8 | Non-default servers may not have ssl context created if there are no
|
|---|
| 9 | certificate defined. Make sure to check if ssl context present before
|
|---|
| 10 | using it.
|
|---|
| 11 |
|
|---|
| 12 | diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
|
|---|
| 13 | --- a/src/http/ngx_http_request.c
|
|---|
| 14 | +++ b/src/http/ngx_http_request.c
|
|---|
| 15 | @@ -671,25 +671,27 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *
|
|---|
| 16 |
|
|---|
| 17 | sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
|
|---|
| 18 |
|
|---|
| 19 | - SSL_set_SSL_CTX(ssl_conn, sscf->ssl.ctx);
|
|---|
| 20 | -
|
|---|
| 21 | - /*
|
|---|
| 22 | - * SSL_set_SSL_CTX() only changes certs as of 1.0.0d
|
|---|
| 23 | - * adjust other things we care about
|
|---|
| 24 | - */
|
|---|
| 25 | -
|
|---|
| 26 | - SSL_set_verify(ssl_conn, SSL_CTX_get_verify_mode(sscf->ssl.ctx),
|
|---|
| 27 | - SSL_CTX_get_verify_callback(sscf->ssl.ctx));
|
|---|
| 28 | -
|
|---|
| 29 | - SSL_set_verify_depth(ssl_conn, SSL_CTX_get_verify_depth(sscf->ssl.ctx));
|
|---|
| 30 | + if (sscf->ssl.ctx) {
|
|---|
| 31 | + SSL_set_SSL_CTX(ssl_conn, sscf->ssl.ctx);
|
|---|
| 32 | +
|
|---|
| 33 | + /*
|
|---|
| 34 | + * SSL_set_SSL_CTX() only changes certs as of 1.0.0d
|
|---|
| 35 | + * adjust other things we care about
|
|---|
| 36 | + */
|
|---|
| 37 | +
|
|---|
| 38 | + SSL_set_verify(ssl_conn, SSL_CTX_get_verify_mode(sscf->ssl.ctx),
|
|---|
| 39 | + SSL_CTX_get_verify_callback(sscf->ssl.ctx));
|
|---|
| 40 | +
|
|---|
| 41 | + SSL_set_verify_depth(ssl_conn, SSL_CTX_get_verify_depth(sscf->ssl.ctx));
|
|---|
| 42 |
|
|---|
| 43 | #ifdef SSL_CTRL_CLEAR_OPTIONS
|
|---|
| 44 | - /* only in 0.9.8m+ */
|
|---|
| 45 | - SSL_clear_options(ssl_conn, SSL_get_options(ssl_conn) &
|
|---|
| 46 | - ~SSL_CTX_get_options(sscf->ssl.ctx));
|
|---|
| 47 | + /* only in 0.9.8m+ */
|
|---|
| 48 | + SSL_clear_options(ssl_conn, SSL_get_options(ssl_conn) &
|
|---|
| 49 | + ~SSL_CTX_get_options(sscf->ssl.ctx));
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | - SSL_set_options(ssl_conn, SSL_CTX_get_options(sscf->ssl.ctx));
|
|---|
| 53 | + SSL_set_options(ssl_conn, SSL_CTX_get_options(sscf->ssl.ctx));
|
|---|
| 54 | + }
|
|---|
| 55 |
|
|---|
| 56 | return SSL_TLSEXT_ERR_OK;
|
|---|
| 57 | }
|
|---|