summaryrefslogtreecommitdiffstats
path: root/meta-webserver/recipes-httpd/apache2/apache2-2.4.3/httpd-2.4.2-r1332643.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-webserver/recipes-httpd/apache2/apache2-2.4.3/httpd-2.4.2-r1332643.patch')
-rw-r--r--meta-webserver/recipes-httpd/apache2/apache2-2.4.3/httpd-2.4.2-r1332643.patch260
1 files changed, 260 insertions, 0 deletions
diff --git a/meta-webserver/recipes-httpd/apache2/apache2-2.4.3/httpd-2.4.2-r1332643.patch b/meta-webserver/recipes-httpd/apache2/apache2-2.4.3/httpd-2.4.2-r1332643.patch
new file mode 100644
index 000000000..16fd7d75b
--- /dev/null
+++ b/meta-webserver/recipes-httpd/apache2/apache2-2.4.3/httpd-2.4.2-r1332643.patch
@@ -0,0 +1,260 @@
1Add support for TLS Next Protocol Negotiation:
2
3* modules/ssl/mod_ssl.c, modules/ssl/mod_ssl.h: Add and implement new
4 hooks for next protocol advertisement/discovery.
5
6* modules/ssl/ssl_engine_init.c (ssl_init_ctx_callbacks): Enable
7 NPN advertisement callback in handshake.
8
9* modules/ssl/ssl_engine_io.c (ssl_io_filter_input): Invoke
10 next-protocol discovery hook.
11
12* modules/ssl/ssl_engine_kernel.c (ssl_callback_AdvertiseNextProtos):
13 New callback.
14
15* modules/ssl/ssl_private.h: Add prototype.
16
17Submitted by: Matthew Steele <mdsteele google.com>
18 with slight tweaks by jorton
19
20https://bugzilla.redhat.com//show_bug.cgi?id=809599
21
22http://svn.apache.org/viewvc?view=revision&revision=1332643
23
24Upstream-Status: Backport
25
26--- httpd-2.4.2/modules/ssl/ssl_private.h
27+++ httpd-2.4.2/modules/ssl/ssl_private.h
28@@ -139,6 +139,11 @@
29 #define HAVE_FIPS
30 #endif
31
32+#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_NEXTPROTONEG) \
33+ && !defined(OPENSSL_NO_TLSEXT)
34+#define HAVE_TLS_NPN
35+#endif
36+
37 #if (OPENSSL_VERSION_NUMBER >= 0x10000000)
38 #define MODSSL_SSL_CIPHER_CONST const
39 #define MODSSL_SSL_METHOD_CONST const
40@@ -811,6 +816,7 @@
41 int ssl_callback_SessionTicket(SSL *, unsigned char *, unsigned char *,
42 EVP_CIPHER_CTX *, HMAC_CTX *, int);
43 #endif
44+int ssl_callback_AdvertiseNextProtos(SSL *ssl, const unsigned char **data, unsigned int *len, void *arg);
45
46 /** Session Cache Support */
47 void ssl_scache_init(server_rec *, apr_pool_t *);
48--- httpd-2.4.2/modules/ssl/mod_ssl.c
49+++ httpd-2.4.2/modules/ssl/mod_ssl.c
50@@ -260,6 +260,18 @@
51 AP_END_CMD
52 };
53
54+/* Implement 'modssl_run_npn_advertise_protos_hook'. */
55+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(
56+ modssl, AP, int, npn_advertise_protos_hook,
57+ (conn_rec *connection, apr_array_header_t *protos),
58+ (connection, protos), OK, DECLINED);
59+
60+/* Implement 'modssl_run_npn_proto_negotiated_hook'. */
61+APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(
62+ modssl, AP, int, npn_proto_negotiated_hook,
63+ (conn_rec *connection, const char *proto_name, apr_size_t proto_name_len),
64+ (connection, proto_name, proto_name_len), OK, DECLINED);
65+
66 /*
67 * the various processing hooks
68 */
69--- httpd-2.4.2/modules/ssl/mod_ssl.h
70+++ httpd-2.4.2/modules/ssl/mod_ssl.h
71@@ -63,5 +63,26 @@
72
73 APR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
74
75+/** The npn_advertise_protos optional hook allows other modules to add entries
76+ * to the list of protocol names advertised by the server during the Next
77+ * Protocol Negotiation (NPN) portion of the SSL handshake. The hook callee is
78+ * given the connection and an APR array; it should push one or more char*'s
79+ * pointing to null-terminated strings (such as "http/1.1" or "spdy/2") onto
80+ * the array and return OK, or do nothing and return DECLINED. */
81+APR_DECLARE_EXTERNAL_HOOK(modssl, AP, int, npn_advertise_protos_hook,
82+ (conn_rec *connection, apr_array_header_t *protos));
83+
84+/** The npn_proto_negotiated optional hook allows other modules to discover the
85+ * name of the protocol that was chosen during the Next Protocol Negotiation
86+ * (NPN) portion of the SSL handshake. Note that this may be the empty string
87+ * (in which case modules should probably assume HTTP), or it may be a protocol
88+ * that was never even advertised by the server. The hook callee is given the
89+ * connection, a non-null-terminated string containing the protocol name, and
90+ * the length of the string; it should do something appropriate (i.e. insert or
91+ * remove filters) and return OK, or do nothing and return DECLINED. */
92+APR_DECLARE_EXTERNAL_HOOK(modssl, AP, int, npn_proto_negotiated_hook,
93+ (conn_rec *connection, const char *proto_name,
94+ apr_size_t proto_name_len));
95+
96 #endif /* __MOD_SSL_H__ */
97 /** @} */
98--- httpd-2.4.2/modules/ssl/ssl_engine_init.c
99+++ httpd-2.4.2/modules/ssl/ssl_engine_init.c
100@@ -681,6 +681,11 @@
101 #endif
102
103 SSL_CTX_set_info_callback(ctx, ssl_callback_Info);
104+
105+#ifdef HAVE_TLS_NPN
106+ SSL_CTX_set_next_protos_advertised_cb(
107+ ctx, ssl_callback_AdvertiseNextProtos, NULL);
108+#endif
109 }
110
111 static void ssl_init_ctx_verify(server_rec *s,
112--- httpd-2.4.2/modules/ssl/ssl_engine_io.c
113+++ httpd-2.4.2/modules/ssl/ssl_engine_io.c
114@@ -28,6 +28,7 @@
115 core keeps dumping.''
116 -- Unknown */
117 #include "ssl_private.h"
118+#include "mod_ssl.h"
119 #include "apr_date.h"
120
121 /* _________________________________________________________________
122@@ -297,6 +298,7 @@
123 apr_pool_t *pool;
124 char buffer[AP_IOBUFSIZE];
125 ssl_filter_ctx_t *filter_ctx;
126+ int npn_finished; /* 1 if NPN has finished, 0 otherwise */
127 } bio_filter_in_ctx_t;
128
129 /*
130@@ -1374,6 +1376,27 @@
131 APR_BRIGADE_INSERT_TAIL(bb, bucket);
132 }
133
134+#ifdef HAVE_TLS_NPN
135+ /* By this point, Next Protocol Negotiation (NPN) should be completed (if
136+ * our version of OpenSSL supports it). If we haven't already, find out
137+ * which protocol was decided upon and inform other modules by calling
138+ * npn_proto_negotiated_hook. */
139+ if (!inctx->npn_finished) {
140+ const unsigned char *next_proto = NULL;
141+ unsigned next_proto_len = 0;
142+
143+ SSL_get0_next_proto_negotiated(
144+ inctx->ssl, &next_proto, &next_proto_len);
145+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, f->c,
146+ "SSL NPN negotiated protocol: '%s'",
147+ apr_pstrmemdup(f->c->pool, (const char*)next_proto,
148+ next_proto_len));
149+ modssl_run_npn_proto_negotiated_hook(
150+ f->c, (const char*)next_proto, next_proto_len);
151+ inctx->npn_finished = 1;
152+ }
153+#endif
154+
155 return APR_SUCCESS;
156 }
157
158@@ -1855,6 +1878,7 @@
159 inctx->block = APR_BLOCK_READ;
160 inctx->pool = c->pool;
161 inctx->filter_ctx = filter_ctx;
162+ inctx->npn_finished = 0;
163 }
164
165 /* The request_rec pointer is passed in here only to ensure that the
166--- httpd-2.4.2/modules/ssl/ssl_engine_kernel.c
167+++ httpd-2.4.2/modules/ssl/ssl_engine_kernel.c
168@@ -29,6 +29,7 @@
169 time I was too famous.''
170 -- Unknown */
171 #include "ssl_private.h"
172+#include "mod_ssl.h"
173 #include "util_md5.h"
174
175 static void ssl_configure_env(request_rec *r, SSLConnRec *sslconn);
176@@ -2143,3 +2144,84 @@
177 return -1;
178 }
179 #endif
180+
181+#ifdef HAVE_TLS_NPN
182+/*
183+ * This callback function is executed when SSL needs to decide what protocols
184+ * to advertise during Next Protocol Negotiation (NPN). It must produce a
185+ * string in wire format -- a sequence of length-prefixed strings -- indicating
186+ * the advertised protocols. Refer to SSL_CTX_set_next_protos_advertised_cb
187+ * in OpenSSL for reference.
188+ */
189+int ssl_callback_AdvertiseNextProtos(SSL *ssl, const unsigned char **data_out,
190+ unsigned int *size_out, void *arg)
191+{
192+ conn_rec *c = (conn_rec*)SSL_get_app_data(ssl);
193+ apr_array_header_t *protos;
194+ int num_protos;
195+ unsigned int size;
196+ int i;
197+ unsigned char *data;
198+ unsigned char *start;
199+
200+ *data_out = NULL;
201+ *size_out = 0;
202+
203+ /* If the connection object is not available, then there's nothing for us
204+ * to do. */
205+ if (c == NULL) {
206+ return SSL_TLSEXT_ERR_OK;
207+ }
208+
209+ /* Invoke our npn_advertise_protos hook, giving other modules a chance to
210+ * add alternate protocol names to advertise. */
211+ protos = apr_array_make(c->pool, 0, sizeof(char*));
212+ modssl_run_npn_advertise_protos_hook(c, protos);
213+ num_protos = protos->nelts;
214+
215+ /* We now have a list of null-terminated strings; we need to concatenate
216+ * them together into a single string, where each protocol name is prefixed
217+ * by its length. First, calculate how long that string will be. */
218+ size = 0;
219+ for (i = 0; i < num_protos; ++i) {
220+ const char *string = APR_ARRAY_IDX(protos, i, const char*);
221+ unsigned int length = strlen(string);
222+ /* If the protocol name is too long (the length must fit in one byte),
223+ * then log an error and skip it. */
224+ if (length > 255) {
225+ ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c,
226+ "SSL NPN protocol name too long (length=%u): %s",
227+ length, string);
228+ continue;
229+ }
230+ /* Leave room for the length prefix (one byte) plus the protocol name
231+ * itself. */
232+ size += 1 + length;
233+ }
234+
235+ /* If there is nothing to advertise (either because no modules added
236+ * anything to the protos array, or because all strings added to the array
237+ * were skipped), then we're done. */
238+ if (size == 0) {
239+ return SSL_TLSEXT_ERR_OK;
240+ }
241+
242+ /* Now we can build the string. Copy each protocol name string into the
243+ * larger string, prefixed by its length. */
244+ data = apr_palloc(c->pool, size * sizeof(unsigned char));
245+ start = data;
246+ for (i = 0; i < num_protos; ++i) {
247+ const char *string = APR_ARRAY_IDX(protos, i, const char*);
248+ apr_size_t length = strlen(string);
249+ *start = (unsigned char)length;
250+ ++start;
251+ memcpy(start, string, length * sizeof(unsigned char));
252+ start += length;
253+ }
254+
255+ /* Success. */
256+ *data_out = data;
257+ *size_out = size;
258+ return SSL_TLSEXT_ERR_OK;
259+}
260+#endif