Skip to content

Commit

Permalink
SSL: moved c->ssl->handshaked check in server name callback.
Browse files Browse the repository at this point in the history
Server name callback is always called by OpenSSL, even
if server_name extension is not present in ClientHello.  As such,
checking c->ssl->handshaked before the SSL_get_servername() result
should help to more effectively prevent renegotiation in
OpenSSL 1.1.0 - 1.1.0g, where neither SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS
nor SSL_OP_NO_RENEGOTIATION is available.
  • Loading branch information
mdounin committed Mar 5, 2019
1 parent 0808b04 commit 0ad4393
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/http/ngx_http_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,19 +864,19 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
ngx_http_core_loc_conf_t *clcf;
ngx_http_core_srv_conf_t *cscf;

servername = SSL_get_servername(ssl_conn, TLSEXT_NAMETYPE_host_name);

if (servername == NULL) {
return SSL_TLSEXT_ERR_OK;
}

c = ngx_ssl_get_connection(ssl_conn);

if (c->ssl->handshaked) {
*ad = SSL_AD_NO_RENEGOTIATION;
return SSL_TLSEXT_ERR_ALERT_FATAL;
}

servername = SSL_get_servername(ssl_conn, TLSEXT_NAMETYPE_host_name);

if (servername == NULL) {
return SSL_TLSEXT_ERR_OK;
}

ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"SSL server name: \"%s\"", servername);

Expand Down

0 comments on commit 0ad4393

Please sign in to comment.