Skip to content

Commit 30b30d5

Browse files
amadioesindril
authored andcommitted
NGINX: add patch to allow enabling proxy certificates
1 parent df6b6a9 commit 30b30d5

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

nginx/nginx-allow-proxy-certs.patch

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
From 0bd39b781ee6053d53d219358c852bc2d433f581 Mon Sep 17 00:00:00 2001
2+
From: Guilherme Amadio <[email protected]>
3+
Date: Mon, 1 Jul 2024 16:49:28 +0200
4+
Subject: [PATCH] SSL: add ssl_allow_proxy_certs flag
5+
6+
---
7+
src/event/ngx_event_openssl.c | 21 +++++++++++++++++++++
8+
src/event/ngx_event_openssl.h | 2 ++
9+
src/http/modules/ngx_http_ssl_module.c | 13 +++++++++++++
10+
src/http/modules/ngx_http_ssl_module.h | 1 +
11+
4 files changed, 37 insertions(+)
12+
13+
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
14+
index c38aa27f1..2b785abb6 100644
15+
--- a/src/event/ngx_event_openssl.c
16+
+++ b/src/event/ngx_event_openssl.c
17+
@@ -1625,6 +1625,27 @@ ngx_ssl_conf_commands(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_array_t *commands)
18+
#endif
19+
}
20+
21+
+ngx_int_t
22+
+ngx_ssl_allow_proxy_certs(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_uint_t enable)
23+
+{
24+
+ X509_STORE *store;
25+
+
26+
+ if (!enable) {
27+
+ return NGX_OK;
28+
+ }
29+
+
30+
+ store = SSL_CTX_get_cert_store(ssl->ctx);
31+
+
32+
+ if (store == NULL) {
33+
+ ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
34+
+ "SSL_CTX_get_cert_store() failed");
35+
+ return NGX_ERROR;
36+
+ }
37+
+
38+
+ X509_STORE_set_flags(store, X509_V_FLAG_ALLOW_PROXY_CERTS);
39+
+
40+
+ return NGX_OK;
41+
+}
42+
43+
ngx_int_t
44+
ngx_ssl_client_session_cache(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_uint_t enable)
45+
diff --git a/src/event/ngx_event_openssl.h b/src/event/ngx_event_openssl.h
46+
index c062f912c..f1bc6f24e 100644
47+
--- a/src/event/ngx_event_openssl.h
48+
+++ b/src/event/ngx_event_openssl.h
49+
@@ -209,6 +209,8 @@ ngx_int_t ngx_ssl_stapling(ngx_conf_t *cf, ngx_ssl_t *ssl,
50+
ngx_str_t *file, ngx_str_t *responder, ngx_uint_t verify);
51+
ngx_int_t ngx_ssl_stapling_resolver(ngx_conf_t *cf, ngx_ssl_t *ssl,
52+
ngx_resolver_t *resolver, ngx_msec_t resolver_timeout);
53+
+ngx_int_t ngx_ssl_allow_proxy_certs(ngx_conf_t *cf, ngx_ssl_t *ssl,
54+
+ ngx_uint_t enable);
55+
ngx_int_t ngx_ssl_ocsp(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *responder,
56+
ngx_uint_t depth, ngx_shm_zone_t *shm_zone);
57+
ngx_int_t ngx_ssl_ocsp_resolver(ngx_conf_t *cf, ngx_ssl_t *ssl,
58+
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
59+
index d2ca475d3..c415d8ec8 100644
60+
--- a/src/http/modules/ngx_http_ssl_module.c
61+
+++ b/src/http/modules/ngx_http_ssl_module.c
62+
@@ -304,6 +304,13 @@ static ngx_command_t ngx_http_ssl_commands[] = {
63+
offsetof(ngx_http_ssl_srv_conf_t, reject_handshake),
64+
NULL },
65+
66+
+ { ngx_string("ssl_allow_proxy_certs"),
67+
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
68+
+ ngx_conf_set_flag_slot,
69+
+ NGX_HTTP_SRV_CONF_OFFSET,
70+
+ offsetof(ngx_http_ssl_srv_conf_t, allow_proxy_certs),
71+
+ NULL },
72+
+
73+
ngx_null_command
74+
};
75+
76+
@@ -636,6 +643,7 @@ ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
77+
sscf->ocsp_cache_zone = NGX_CONF_UNSET_PTR;
78+
sscf->stapling = NGX_CONF_UNSET;
79+
sscf->stapling_verify = NGX_CONF_UNSET;
80+
+ sscf->allow_proxy_certs = NGX_CONF_UNSET;
81+
82+
return sscf;
83+
}
84+
@@ -711,6 +719,7 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
85+
ngx_conf_merge_str_value(conf->stapling_file, prev->stapling_file, "");
86+
ngx_conf_merge_str_value(conf->stapling_responder,
87+
prev->stapling_responder, "");
88+
+ ngx_conf_merge_value(conf->allow_proxy_certs, prev->allow_proxy_certs, 1);
89+
90+
conf->ssl.log = cf->log;
91+
92+
@@ -938,6 +947,10 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
93+
return NGX_CONF_ERROR;
94+
}
95+
96+
+ if (ngx_ssl_allow_proxy_certs(cf, &conf->ssl, conf->allow_proxy_certs) != NGX_OK) {
97+
+ return NGX_CONF_ERROR;
98+
+ }
99+
+
100+
return NGX_CONF_OK;
101+
}
102+
103+
diff --git a/src/http/modules/ngx_http_ssl_module.h b/src/http/modules/ngx_http_ssl_module.h
104+
index 7ab0f7eae..9c2280bec 100644
105+
--- a/src/http/modules/ngx_http_ssl_module.h
106+
+++ b/src/http/modules/ngx_http_ssl_module.h
107+
@@ -64,6 +64,7 @@ typedef struct {
108+
ngx_flag_t stapling_verify;
109+
ngx_str_t stapling_file;
110+
ngx_str_t stapling_responder;
111+
+ ngx_flag_t allow_proxy_certs;
112+
113+
u_char *file;
114+
ngx_uint_t line;
115+
--
116+
2.45.2
117+

nginx/nginx.spec

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Source6: nginx.service
5959
Source7: nginx.sysconfig.systemd
6060

6161
Patch0: nginx-allow-put-redirect.patch
62+
Patch1: nginx-allow-proxy-certs.patch
6263
Patch2: nginx-no-body-before-redirect.patch
6364

6465
%description
@@ -72,6 +73,7 @@ A second third party modul, nginx-auth-ldap has been added.
7273
%setup -q -n nginx-%{version}
7374

7475
%patch0 -p1
76+
%patch1 -p1
7577
%patch2 -p1
7678
%build
7779

0 commit comments

Comments
 (0)