mirror of
https://github.com/nginx/nginx.git
synced 2024-12-19 05:33:52 -06:00
SSL: fixed possible segfault with dynamic certificates.
A virtual server may have no SSL context if it does not have certificates defined, so we have to use config of the ngx_http_ssl_module from the SSL context in the certificate callback. To do so, it is now passed as the argument of the callback. The stream module doesn't really need any changes, but was modified as well to match http code.
This commit is contained in:
parent
ecfab06cb2
commit
1a30d79c42
@ -741,7 +741,7 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
|
||||
/* install callback to lookup certificates */
|
||||
|
||||
SSL_CTX_set_cert_cb(conf->ssl.ctx, ngx_http_ssl_certificate, NULL);
|
||||
SSL_CTX_set_cert_cb(conf->ssl.ctx, ngx_http_ssl_certificate, conf);
|
||||
|
||||
#else
|
||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||
|
@ -973,7 +973,7 @@ ngx_http_ssl_certificate(ngx_ssl_conn_t *ssl_conn, void *arg)
|
||||
|
||||
r->logged = 1;
|
||||
|
||||
sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
|
||||
sscf = arg;
|
||||
|
||||
nelts = sscf->certificate_values->nelts;
|
||||
certs = sscf->certificate_values->elts;
|
||||
|
@ -434,7 +434,7 @@ ngx_stream_ssl_certificate(ngx_ssl_conn_t *ssl_conn, void *arg)
|
||||
|
||||
s = c->data;
|
||||
|
||||
sslcf = ngx_stream_get_module_srv_conf(s, ngx_stream_ssl_module);
|
||||
sslcf = arg;
|
||||
|
||||
nelts = sslcf->certificate_values->nelts;
|
||||
certs = sslcf->certificate_values->elts;
|
||||
@ -692,7 +692,7 @@ ngx_stream_ssl_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
|
||||
/* install callback to lookup certificates */
|
||||
|
||||
SSL_CTX_set_cert_cb(conf->ssl.ctx, ngx_stream_ssl_certificate, NULL);
|
||||
SSL_CTX_set_cert_cb(conf->ssl.ctx, ngx_stream_ssl_certificate, conf);
|
||||
|
||||
#else
|
||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user