View | Details | Raw Unified | Return to bug 49123
Collapse All | Expand All

(-)docs/manual/mod/mod_proxy_ajp.xml (+37 lines)
Lines 50-55 Link Here
50
50
51
<seealso><module>mod_proxy</module></seealso>
51
<seealso><module>mod_proxy</module></seealso>
52
52
53
<directivesynopsis>
54
<name>ProxyAJPForwardSSLCertChain</name>
55
<description>Whether to send the client's SSL certificate chain</description>
56
<syntax>ProxyAJPForwardSSLCertChain on|off</syntax>
57
<default>ProxyAJPForwardSSLCertChain off</default>
58
<contextlist><context>server config</context>
59
<context>virtual host</context></contextlist>
60
<compatibility>Available in Apache ? and later</compatibility>
61
62
<usage>
63
<p>This directive controls whether the client's SSL certificate chain (the
64
client's certificate and all intermediate certificates) or only the client's
65
certificate (without any intermediate certificates) will be sent to the AJP
66
server when proxying an incoming SSL connection. If <code>on</code>, the SSL
67
certificate chain will be sent.</p>
68
<p>This is disabled by default because the default AJP message buffers in both
69
mod_proxy_ajp and Tomcat are not large enough to hold a long certificate chain
70
(more than 1 or 2 intermediate certificates), so clients having a long chain
71
will get errors if this is enabled without first adjusting the AJP message
72
buffer sizes appropriately.</p>
73
<p>To adjust the AJP message buffer size in mod_proxy_ajp, use the
74
<directive module="mod_proxy">ProxyIOBufferSize</directive> directive. The
75
specified size should be large enough to hold the client's (PEM-encoded)
76
certificate and all (PEM-encoded) intermediate certificates, plus 400 bytes or
77
so for other AJP request data. The minimum size is 8192, the maximum is 65536,
78
and the default is 8192.</p>
79
<p>To adjust the AJP message buffer size in Tomcat, specify the
80
<code>packetSize</code> attribute in the AJP connector declaration. The same
81
buffer size should be used for both mod_proxy_ajp and Tomcat.</p>
82
<p>Note that support for processing of intermediate certificates is only
83
available in Tomcat 5.5.28+ and 6.0.21+ (earlier versions will simply ignore
84
the intermediate certificates in the AJP request), and the
85
<code>packetSize</code> attribute is only available in Tomcat 5.5.20+ and
86
6.0.2+ (earlier versions had a fixed buffer size of 8192 bytes).</p>
87
</usage>
88
</directivesynopsis>
89
53
<section id="overviewprotocol"><title>Overview of the protocol</title>
90
<section id="overviewprotocol"><title>Overview of the protocol</title>
54
    <p>The <code>AJP13</code> protocol is packet-oriented.  A binary format
91
    <p>The <code>AJP13</code> protocol is packet-oriented.  A binary format
55
    was presumably chosen over the more readable plain text for reasons of
92
    was presumably chosen over the more readable plain text for reasons of
(-)modules/proxy/ajp_config.h (+47 lines)
Line 0 Link Here
1
/* Licensed to the Apache Software Foundation (ASF) under one or more
2
 * contributor license agreements.  See the NOTICE file distributed with
3
 * this work for additional information regarding copyright ownership.
4
 * The ASF licenses this file to You under the Apache License, Version 2.0
5
 * (the "License"); you may not use this file except in compliance with
6
 * the License.  You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
#ifndef AJP_CONFIG_H
18
#define AJP_CONFIG_H
19
20
/**
21
 * @file  ajp_config.h
22
 * @brief AJP internal configuration management.
23
 *
24
 * @defgroup AJP_config AJP configuration
25
 * @ingroup  MOD_PROXY
26
 * @{
27
 */
28
29
#ifndef BOOL
30
#define BOOL unsigned char
31
#endif
32
#ifndef FALSE
33
#define FALSE (0)
34
#endif
35
#ifndef TRUE
36
#define TRUE (!FALSE)
37
#endif
38
39
typedef struct {
40
    BOOL send_cert_chain;
41
    BOOL send_cert_chain_set;
42
} proxy_ajp_conf;
43
44
extern module AP_MODULE_DECLARE_DATA proxy_ajp_module;
45
46
#endif /*AJP_CONFIG_H*/
47
/** @} */
(-)modules/proxy/ajp.h (+1 lines)
Lines 61-66 Link Here
61
/* The following environment variables match mod_ssl! */
61
/* The following environment variables match mod_ssl! */
62
#define AJP13_HTTPS_INDICATOR           "HTTPS"
62
#define AJP13_HTTPS_INDICATOR           "HTTPS"
63
#define AJP13_SSL_CLIENT_CERT_INDICATOR "SSL_CLIENT_CERT"
63
#define AJP13_SSL_CLIENT_CERT_INDICATOR "SSL_CLIENT_CERT"
64
#define AJP13_SSL_CLIENT_CHAIN_PREFIX   "SSL_CLIENT_CERT_CHAIN_"
64
#define AJP13_SSL_CIPHER_INDICATOR      "SSL_CIPHER"
65
#define AJP13_SSL_CIPHER_INDICATOR      "SSL_CIPHER"
65
#define AJP13_SSL_SESSION_INDICATOR     "SSL_SESSION_ID"
66
#define AJP13_SSL_SESSION_INDICATOR     "SSL_SESSION_ID"
66
#define AJP13_SSL_KEY_SIZE_INDICATOR    "SSL_CIPHER_USEKEYSIZE"
67
#define AJP13_SSL_KEY_SIZE_INDICATOR    "SSL_CIPHER_USEKEYSIZE"
(-)modules/proxy/mod_proxy_ajp.c (-3 / +49 lines)
Lines 18-26 Link Here
18
18
19
#include "mod_proxy.h"
19
#include "mod_proxy.h"
20
#include "ajp.h"
20
#include "ajp.h"
21
#include "ajp_config.h"
21
22
22
module AP_MODULE_DECLARE_DATA proxy_ajp_module;
23
module AP_MODULE_DECLARE_DATA proxy_ajp_module;
23
24
25
static void *create_proxy_ajp_config(apr_pool_t *p, server_rec *s)
26
{
27
    proxy_ajp_conf *c = apr_pcalloc(p, sizeof(proxy_ajp_conf));
28
    c->send_cert_chain = FALSE;
29
    c->send_cert_chain_set = FALSE;
30
    return c;
31
}
32
33
static void *merge_proxy_ajp_config(apr_pool_t *p, void *basev, void *overridesv)
34
{
35
    proxy_ajp_conf *c = apr_pcalloc(p, sizeof(proxy_ajp_conf));
36
    proxy_ajp_conf *base = (proxy_ajp_conf *) basev;
37
    proxy_ajp_conf *overrides = (proxy_ajp_conf *) overridesv;
38
    c->send_cert_chain = (overrides->send_cert_chain_set ?
39
                          overrides->send_cert_chain : base->send_cert_chain);
40
    c->send_cert_chain_set = (base->send_cert_chain_set ||
41
                              overrides->send_cert_chain_set);
42
    return c;
43
}
44
45
static const char *
46
    set_forward_cert_chain(cmd_parms *params, void *dummy, const char *arg)
47
{
48
    proxy_ajp_conf *c =
49
        ap_get_module_config(params->server->module_config, &proxy_ajp_module);
50
51
    if (strcasecmp(arg, "Off") == 0)
52
        c->send_cert_chain = FALSE;
53
    else if (strcasecmp(arg, "On") == 0)
54
        c->send_cert_chain = TRUE;
55
    else
56
        return "ProxyAJPForwardSSLCertChain must be one of: On | Off";
57
58
    c->send_cert_chain_set = TRUE;
59
    return NULL;
60
}
61
24
/*
62
/*
25
 * Canonicalise http-like URLs.
63
 * Canonicalise http-like URLs.
26
 * scheme is the scheme for the URL
64
 * scheme is the scheme for the URL
Lines 724-736 Link Here
724
    proxy_hook_canon_handler(proxy_ajp_canon, NULL, NULL, APR_HOOK_FIRST);
762
    proxy_hook_canon_handler(proxy_ajp_canon, NULL, NULL, APR_HOOK_FIRST);
725
}
763
}
726
764
765
static const command_rec proxy_ajp_cmds[] =
766
{
767
    AP_INIT_TAKE1("ProxyAJPForwardSSLCertChain", set_forward_cert_chain, NULL,
768
                  RSRC_CONF, "Forward the entire SSL Certificate Chain "
769
                  "('on', 'off')"),
770
    {NULL}
771
};
772
727
module AP_MODULE_DECLARE_DATA proxy_ajp_module = {
773
module AP_MODULE_DECLARE_DATA proxy_ajp_module = {
728
    STANDARD20_MODULE_STUFF,
774
    STANDARD20_MODULE_STUFF,
729
    NULL,                       /* create per-directory config structure */
775
    NULL,                       /* create per-directory config structure */
730
    NULL,                       /* merge per-directory config structures */
776
    NULL,                       /* merge per-directory config structures */
731
    NULL,                       /* create per-server config structure */
777
    create_proxy_ajp_config,    /* create per-server config structure */
732
    NULL,                       /* merge per-server config structures */
778
    merge_proxy_ajp_config,     /* merge per-server config structures */
733
    NULL,                       /* command apr_table_t */
779
    proxy_ajp_cmds,             /* command apr_table_t */
734
    ap_proxy_http_register_hook /* register hooks */
780
    ap_proxy_http_register_hook /* register hooks */
735
};
781
};
736
782
(-)modules/proxy/ajp_header.c (-1 / +19 lines)
Lines 16-21 Link Here
16
16
17
#include "ajp_header.h"
17
#include "ajp_header.h"
18
#include "ajp.h"
18
#include "ajp.h"
19
#include "ajp_config.h"
19
20
20
static const char *response_trans_headers[] = {
21
static const char *response_trans_headers[] = {
21
    "Content-Type",
22
    "Content-Type",
Lines 200-206 Link Here
200
    ?auth_type     (byte)(string)
201
    ?auth_type     (byte)(string)
201
    ?query_string  (byte)(string)
202
    ?query_string  (byte)(string)
202
    ?jvm_route     (byte)(string)
203
    ?jvm_route     (byte)(string)
203
    ?ssl_cert      (byte)(string)
204
    ?ssl_certs     (byte)(string)
204
    ?ssl_cipher    (byte)(string)
205
    ?ssl_cipher    (byte)(string)
205
    ?ssl_session   (byte)(string)
206
    ?ssl_session   (byte)(string)
206
    ?ssl_key_size  (byte)(int)      via JkOptions +ForwardKeySize
207
    ?ssl_key_size  (byte)(int)      via JkOptions +ForwardKeySize
Lines 220-225 Link Here
220
    const char *session_route, *envvar;
221
    const char *session_route, *envvar;
221
    const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
222
    const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
222
    const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
223
    const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
224
    proxy_ajp_conf *sc =
225
        ap_get_module_config(r->server->module_config, &proxy_ajp_module);
223
226
224
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
227
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
225
                         "Into ajp_marshal_into_msgb");
228
                         "Into ajp_marshal_into_msgb");
Lines 356-361 Link Here
356
        if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
359
        if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
357
                                       AJP13_SSL_CLIENT_CERT_INDICATOR))
360
                                       AJP13_SSL_CLIENT_CERT_INDICATOR))
358
            && envvar[0]) {
361
            && envvar[0]) {
362
            /* If ProxyAJPForwardSSLCertChain is set, send the entire chain */
363
            if (sc->send_cert_chain) {
364
                apr_array_header_t *certs = apr_array_make(r->pool, 1, sizeof(char *));
365
                int i = 0;
366
                char *envvar_name;
367
                do {
368
                  *(const char **)apr_array_push(certs) = envvar;
369
                  envvar_name = apr_psprintf(r->pool, "%s%d",
370
                                             AJP13_SSL_CLIENT_CHAIN_PREFIX, i);
371
                  envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
372
                                            envvar_name);
373
                  i++;
374
                } while (envvar && envvar[0]);
375
                envvar = apr_array_pstrcat(r->pool, certs, '\0');
376
            }
359
            if (ajp_msg_append_uint8(msg, SC_A_SSL_CERT)
377
            if (ajp_msg_append_uint8(msg, SC_A_SSL_CERT)
360
                || ajp_msg_append_string(msg, envvar)) {
378
                || ajp_msg_append_string(msg, envvar)) {
361
                ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
379
                ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,

Return to bug 49123