Skip to content

Commit 69a5ca0

Browse files
committed
f
Signed-off-by: Nic <[email protected]>
1 parent af6b6fb commit 69a5ca0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

patch/1.21.4/nginx-sni_restriction.patch

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git src/http/ngx_http_request.c src/http/ngx_http_request.c
2-
index 013b7158e..d5ac3d415 100644
2+
index 013b7158e..0f8e981b5 100644
33
--- src/http/ngx_http_request.c
44
+++ src/http/ngx_http_request.c
55
@@ -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
4343
c->ssl->buffer_size = sscf->buffer_size;
4444

4545
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

Comments
 (0)