1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

ALPN support, based on mod_spdy/mod_h2 patch set

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1670397 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Jagielski
2015-03-31 17:12:51 +00:00
parent 5524cbd29b
commit 17565ac48c
5 changed files with 161 additions and 0 deletions

View File

@@ -316,6 +316,7 @@ typedef struct {
char buffer[AP_IOBUFSIZE];
ssl_filter_ctx_t *filter_ctx;
int npn_finished; /* 1 if NPN has finished, 0 otherwise */
int alpn_finished; /* 1 if ALPN has finished, 0 otherwise */
} bio_filter_in_ctx_t;
/*
@@ -1483,6 +1484,37 @@ static apr_status_t ssl_io_filter_input(ap_filter_t *f,
APR_BRIGADE_INSERT_TAIL(bb, bucket);
}
#ifdef HAVE_TLS_ALPN
/* By this point, Application-Layer Protocol Negotiation (ALPN) should be
* completed (if our version of OpenSSL supports it). If we haven't already,
* find out which protocol was decided upon and inform other modules
* by calling alpn_proto_negotiated_hook.
*/
if (!inctx->alpn_finished) {
SSLConnRec *sslconn = myConnConfig(f->c);
const unsigned char *next_proto = NULL;
unsigned next_proto_len = 0;
int n;
if (sslconn->alpn_negofns) {
SSL_get0_alpn_selected(inctx->ssl, &next_proto, &next_proto_len);
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, f->c,
APLOGNO() "SSL negotiated protocol: '%s'",
(next_proto && next_proto_len)?
apr_pstrmemdup(f->c->pool, (const char *)next_proto,
next_proto_len) : "(null)");
for (n = 0; n < sslconn->alpn_negofns->nelts; n++) {
ssl_alpn_proto_negotiated fn =
APR_ARRAY_IDX(sslconn->alpn_negofns, n, ssl_alpn_proto_negotiated);
if (fn(f->c, (const char *)next_proto, next_proto_len) == DONE)
break;
}
}
inctx->alpn_finished = 1;
}
#endif
#ifdef HAVE_TLS_NPN
/* By this point, Next Protocol Negotiation (NPN) should be completed (if
* our version of OpenSSL supports it). If we haven't already, find out
@@ -1995,6 +2027,7 @@ static void ssl_io_input_add_filter(ssl_filter_ctx_t *filter_ctx, conn_rec *c,
inctx->pool = c->pool;
inctx->filter_ctx = filter_ctx;
inctx->npn_finished = 0;
inctx->alpn_finished = 0;
}
/* The request_rec pointer is passed in here only to ensure that the