Skip to content

Commit a45254c

Browse files
committed
add patch for 1.27
Signed-off-by: Nic <[email protected]>
1 parent 97d7823 commit a45254c

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
diff --git src/ngx_http_lua_ssl_certby.c src/ngx_http_lua_ssl_certby.c
2+
index 72a651bd..7db28e10 100644
3+
--- src/ngx_http_lua_ssl_certby.c
4+
+++ src/ngx_http_lua_ssl_certby.c
5+
@@ -870,6 +870,46 @@ ngx_http_lua_ffi_ssl_server_name(ngx_http_request_t *r, char **name,
6+
}
7+
8+
9+
+int
10+
+ngx_http_lua_ffi_ssl_session_hostname(ngx_http_request_t *r, char **name,
11+
+ size_t *namelen, char **err)
12+
+{
13+
+ ngx_ssl_conn_t *ssl_conn;
14+
+
15+
+ if (r->connection == NULL || r->connection->ssl == NULL) {
16+
+ *err = "bad request";
17+
+ return NGX_ERROR;
18+
+ }
19+
+
20+
+ ssl_conn = r->connection->ssl->connection;
21+
+ if (ssl_conn == NULL) {
22+
+ *err = "bad ssl conn";
23+
+ return NGX_ERROR;
24+
+ }
25+
+
26+
+#if (defined(TLS1_3_VERSION) \
27+
+ && !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_IS_BORINGSSL))
28+
+
29+
+ /*
30+
+ * SSL_SESSION_get0_hostname() is only available in OpenSSL 1.1.1+,
31+
+ * but servername being negotiated in every TLSv1.3 handshake
32+
+ * is only returned in OpenSSL 1.1.1+ as well
33+
+ */
34+
+
35+
+ *name = (char *) SSL_SESSION_get0_hostname(SSL_get0_session(ssl_conn));
36+
+
37+
+ if (*name) {
38+
+ *namelen = ngx_strlen(*name);
39+
+ return NGX_OK;
40+
+ }
41+
+#endif
42+
+
43+
+ *name = "";
44+
+ *namelen = 0;
45+
+ return NGX_OK;
46+
+}
47+
+
48+
+
49+
int
50+
ngx_http_lua_ffi_ssl_server_port(ngx_http_request_t *r,
51+
unsigned short *server_port, char **err)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
diff --git src/ngx_stream_lua_ssl_certby.c src/ngx_stream_lua_ssl_certby.c
2+
index a34e187..0f65d82 100644
3+
--- src/ngx_stream_lua_ssl_certby.c
4+
+++ src/ngx_stream_lua_ssl_certby.c
5+
@@ -884,6 +884,46 @@ ngx_stream_lua_ffi_ssl_server_name(ngx_stream_lua_request_t *r, char **name,
6+
}
7+
8+
9+
+int
10+
+ngx_stream_lua_ffi_ssl_session_hostname(ngx_stream_lua_request_t *r, char **name,
11+
+ size_t *namelen, char **err)
12+
+{
13+
+ ngx_ssl_conn_t *ssl_conn;
14+
+
15+
+ if (r->connection == NULL || r->connection->ssl == NULL) {
16+
+ *err = "bad request";
17+
+ return NGX_ERROR;
18+
+ }
19+
+
20+
+ ssl_conn = r->connection->ssl->connection;
21+
+ if (ssl_conn == NULL) {
22+
+ *err = "bad ssl conn";
23+
+ return NGX_ERROR;
24+
+ }
25+
+
26+
+#if (defined(TLS1_3_VERSION) \
27+
+ && !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_IS_BORINGSSL))
28+
+
29+
+ /*
30+
+ * SSL_SESSION_get0_hostname() is only available in OpenSSL 1.1.1+,
31+
+ * but servername being negotiated in every TLSv1.3 handshake
32+
+ * is only returned in OpenSSL 1.1.1+ as well
33+
+ */
34+
+
35+
+ *name = (char *) SSL_SESSION_get0_hostname(SSL_get0_session(ssl_conn));
36+
+
37+
+ if (*name) {
38+
+ *namelen = ngx_strlen(*name);
39+
+ return NGX_OK;
40+
+ }
41+
+#endif
42+
+
43+
+ *name = "";
44+
+ *namelen = 0;
45+
+ return NGX_OK;
46+
+}
47+
+
48+
+
49+
int
50+
ngx_stream_lua_ffi_ssl_server_port(ngx_stream_lua_request_t *r,
51+
unsigned short *server_port, char **err)

0 commit comments

Comments
 (0)