Changeset 33826c5 in mod_gnutls for src/mod_gnutls.c


Ignore:
Timestamp:
Oct 4, 2011, 7:01:32 AM (8 years ago)
Author:
Dash Shendy <neuromancer@…>
Branches:
debian/master, debian/stretch-backports, jessie-backports, master, msva, upstream
Children:
37f8282
Parents:
a4feefc
Message:

mod_proxy support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mod_gnutls.c

    ra4feefc r33826c5  
    2121
    2222static void gnutls_hooks(apr_pool_t * p) {
    23     ap_hook_pre_connection(mgs_hook_pre_connection, NULL, NULL,
    24             APR_HOOK_MIDDLE);
    25     ap_hook_post_config(mgs_hook_post_config, NULL, NULL,
    26             APR_HOOK_MIDDLE);
     23
     24    ap_hook_open_logs(mgs_hook_open_logs, NULL, NULL,APR_HOOK_MIDDLE);
     25    /* Try Run Post-Config Hook After mod_proxy */
     26    static const char * const aszPre[] = { "mod_proxy.c", NULL };
     27    ap_hook_post_config(mgs_hook_post_config, aszPre, NULL,APR_HOOK_REALLY_LAST);
     28    /* HTTP Scheme Hook */
     29#if USING_2_1_RECENT
     30    ap_hook_http_scheme(mgs_hook_http_scheme, NULL, NULL, APR_HOOK_MIDDLE);
     31#else
     32    ap_hook_http_method(mgs_hook_http_scheme, NULL, NULL, APR_HOOK_MIDDLE);
     33#endif
     34    /* Default Port Hook */
     35    ap_hook_default_port(nss_hook_default_port,  NULL,NULL, APR_HOOK_MIDDLE);
     36    /* Pre-Connect Hook */
     37    ap_hook_pre_connection(mgs_hook_default_port, NULL, NULL, APR_HOOK_MIDDLE);
     38    /* Pre-Config Hook */
     39    ap_hook_pre_config(mgs_hook_pre_config, NULL, NULL,
     40            APR_HOOK_MIDDLE);   
     41    /* Child-Init Hook */
    2742    ap_hook_child_init(mgs_hook_child_init, NULL, NULL,
    2843            APR_HOOK_MIDDLE);
    29 #if USING_2_1_RECENT
    30     ap_hook_http_scheme(mgs_hook_http_scheme, NULL, NULL,
    31             APR_HOOK_MIDDLE);
    32 #else
    33     ap_hook_http_method(mgs_hook_http_scheme, NULL, NULL,
    34             APR_HOOK_MIDDLE);
    35 #endif
    36     ap_hook_default_port(mgs_hook_default_port, NULL, NULL,
    37             APR_HOOK_MIDDLE);
    38     ap_hook_pre_config(mgs_hook_pre_config, NULL, NULL,
    39             APR_HOOK_MIDDLE);
    40 
     44    /* Authentication Hook */
    4145    ap_hook_access_checker(mgs_hook_authz, NULL, NULL,
    4246            APR_HOOK_REALLY_FIRST);
    43 
     47    /* Fixups Hook */
    4448    ap_hook_fixups(mgs_hook_fixups, NULL, NULL, APR_HOOK_REALLY_FIRST);
    4549
     
    4953     */
    5054
     55    /* Input Filter */
    5156    ap_register_input_filter(GNUTLS_INPUT_FILTER_NAME,
    52             mgs_filter_input, NULL,
    53             AP_FTYPE_CONNECTION + 5);
     57            mgs_filter_input, NULL,AP_FTYPE_CONNECTION + 5);
     58    /* Output Filter */
    5459    ap_register_output_filter(GNUTLS_OUTPUT_FILTER_NAME,
    55             mgs_filter_output, NULL,
    56             AP_FTYPE_CONNECTION + 5);
     60            mgs_filter_output, NULL,AP_FTYPE_CONNECTION + 5);
     61   
     62    /* mod_proxy calls these functions */
     63    APR_REGISTER_OPTIONAL_FN(ssl_proxy_enable);
     64    APR_REGISTER_OPTIONAL_FN(ssl_engine_disable);
     65}
     66
     67int ssl_is_https(conn_rec *c) {
     68    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     69            ap_get_module_config(c->base_server->module_config, &gnutls_module);
     70    if(sc->enabled == GNUTLS_ENABLED_FALSE || sc->non_ssl_request) {
     71        /* SSL/TLS Disabled or Plain HTTP Connection Detected */
     72        return 0;
     73    }
     74    /* Connection is Using SSL/TLS */
     75    return 1;
     76}
     77
     78int ssl_engine_disable(conn_rec *c) {
     79    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     80            ap_get_module_config(c->base_server->module_config, &gnutls_module);
     81    if(sc->enabled == GNUTLS_ENABLED_FALSE) {
     82        return 1;
     83    }
     84    ap_remove_input_filter(c->input_filters);
     85    ap_remove_input_filter(c->output_filters);
     86    mgs_cleanup_pre_config(c->pool);
     87    sc->enabled = 0;
     88    return 1;
     89}
     90
     91int ssl_proxy_enable(conn_rec *c) {
     92    mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
     93            ap_get_module_config(c->base_server->module_config, &gnutls_module);
     94    return sc->proxy_enabled;
    5795}
    5896
    5997static const command_rec mgs_config_cmds[] = {
     98    AP_INIT_TAKE1("SSLProxyEngine", mgs_set_proxy_engine,
     99    NULL,
     100    RSRC_CONF | OR_AUTHCFG,
     101    "Set Verification Requirements of the Client Certificate"),
    60102    AP_INIT_TAKE1("GnuTLSClientVerify", mgs_set_client_verify,
    61103    NULL,
Note: See TracChangeset for help on using the changeset viewer.