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

mod_ssl: Redesign NPN (Next Protocol Negotiation) API to avoid use of

hooks API and inter-module hard linkage:

* modules/ssl/mod_ssl.h: Remove NPN hooks, add "modssl_register_npn"
  optional function and callback function type declarations for
  ssl_npn_advertise_protos, ssl_npn_proto_negotiated.

* modules/ssl/mod_ssl.c: Drop hooks.
  (modssl_register_npn): New optional function implementation.
  (ssl_register_hooks): Register it.

* modules/ssl/ssl_private.h (SSLConnRec): Add npn_advertfns,
  npn_negofns array fields.

* modules/ssl/ssl_engine_kernel.c (ssl_callback_AdvertiseNextProtos): 
  Replace use of hook API with array iteration.

* modules/ssl/ssl_engine_io.c (ssl_io_filter_input): Likewise.

Reviewed by: Matthew Steele <mdsteele google.com>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1487772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joe Orton
2013-05-30 07:19:07 +00:00
parent 7557b6066f
commit b3ce136d05
5 changed files with 101 additions and 43 deletions

View File

@@ -2186,6 +2186,7 @@ int ssl_callback_AdvertiseNextProtos(SSL *ssl, const unsigned char **data_out,
unsigned int *size_out, void *arg)
{
conn_rec *c = (conn_rec*)SSL_get_app_data(ssl);
SSLConnRec *sslconn = myConnConfig(c);
apr_array_header_t *protos;
int num_protos;
unsigned int size;
@@ -2196,16 +2197,22 @@ int ssl_callback_AdvertiseNextProtos(SSL *ssl, const unsigned char **data_out,
*data_out = NULL;
*size_out = 0;
/* If the connection object is not available, then there's nothing for us
* to do. */
if (c == NULL) {
/* If the connection object is not available, or there are no NPN
* hooks registered, then there's nothing for us to do. */
if (c == NULL || sslconn->npn_advertfns == NULL) {
return SSL_TLSEXT_ERR_OK;
}
/* Invoke our npn_advertise_protos hook, giving other modules a chance to
* add alternate protocol names to advertise. */
protos = apr_array_make(c->pool, 0, sizeof(char*));
modssl_run_npn_advertise_protos_hook(c, protos);
protos = apr_array_make(c->pool, 0, sizeof(char *));
for (i = 0; i < sslconn->npn_advertfns->nelts; i++) {
ssl_npn_advertise_protos fn =
APR_ARRAY_IDX(sslconn->npn_advertfns, i, ssl_npn_advertise_protos);
if (fn(c, protos) == DONE)
break;
}
num_protos = protos->nelts;
/* We now have a list of null-terminated strings; we need to concatenate