|
1 | 1 | diff --git src/http/ngx_http_request.c src/http/ngx_http_request.c |
2 | | -index 013b7158e..d5ac3d415 100644 |
| 2 | +index 013b7158e..0f8e981b5 100644 |
3 | 3 | --- src/http/ngx_http_request.c |
4 | 4 | +++ src/http/ngx_http_request.c |
5 | 5 | @@ -909,6 +909,31 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) |
@@ -43,3 +43,33 @@ index 013b7158e..d5ac3d415 100644 |
43 | 43 | c->ssl->buffer_size = sscf->buffer_size; |
44 | 44 |
|
45 | 45 | if (sscf->ssl.ctx) { |
| 46 | +@@ -958,6 +981,29 @@ done: |
| 47 | + |
| 48 | + sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); |
| 49 | + |
| 50 | ++#if (defined TLS1_3_VERSION \ |
| 51 | ++ && !defined LIBRESSL_VERSION_NUMBER && !defined OPENSSL_IS_BORINGSSL) |
| 52 | ++ |
| 53 | ++ /* |
| 54 | ++ * SSL_SESSION_get0_hostname() is only available in OpenSSL 1.1.1+, |
| 55 | ++ * but servername being negotiated in every TLSv1.3 handshake |
| 56 | ++ * is only returned in OpenSSL 1.1.1+ as well |
| 57 | ++ */ |
| 58 | ++ |
| 59 | ++ if (sscf->verify) { |
| 60 | ++ const char *hostname; |
| 61 | ++ |
| 62 | ++ hostname = SSL_SESSION_get0_hostname(SSL_get0_session(ssl_conn)); |
| 63 | ++ |
| 64 | ++ if (hostname != NULL && ngx_strcmp(hostname, servername) != 0) { |
| 65 | ++ c->ssl->handshake_rejected = 1; |
| 66 | ++ *ad = SSL_AD_ACCESS_DENIED; |
| 67 | ++ return SSL_TLSEXT_ERR_ALERT_FATAL; |
| 68 | ++ } |
| 69 | ++ } |
| 70 | ++ |
| 71 | ++#endif |
| 72 | ++ |
| 73 | + if (sscf->reject_handshake) { |
| 74 | + c->ssl->handshake_rejected = 1; |
| 75 | + *ad = SSL_AD_UNRECOGNIZED_NAME; |
0 commit comments