Changeset 71e9a5c in mod_gnutls for src/mod_gnutls.c
- Timestamp:
- Aug 22, 2015, 3:53:31 PM (6 years ago)
- Branches:
- debian/master, debian/stretch-backports, jessie-backports
- Children:
- b837187
- Parents:
- 2db6923 (diff), 4addf74 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mod_gnutls.c
r2db6923 r71e9a5c 1 1 /** 2 2 * Copyright 2004-2005 Paul Querna 3 * Copyright 2008 Nikos Mavrogiannopoulos3 * Copyright 2008, 2014 Nikos Mavrogiannopoulos 4 4 * Copyright 2011 Dash Shendy 5 * Copyright 2015 Thomas Klute 5 6 * 6 7 * Licensed under the Apache License, Version 2.0 (the "License"); … … 20 21 #include "mod_gnutls.h" 21 22 22 static void gnutls_hooks(apr_pool_t * p) { 23 23 #ifdef APLOG_USE_MODULE 24 APLOG_USE_MODULE(gnutls); 25 #endif 26 27 static void gnutls_hooks(apr_pool_t * p __attribute__((unused))) 28 { 24 29 /* Try Run Post-Config Hook After mod_proxy */ 25 30 static const char * const aszPre[] = { "mod_proxy.c", NULL }; 26 ap_hook_post_config(mgs_hook_post_config, aszPre, NULL,APR_HOOK_REALLY_LAST); 31 ap_hook_post_config(mgs_hook_post_config, aszPre, NULL, 32 APR_HOOK_REALLY_LAST); 27 33 /* HTTP Scheme Hook */ 28 34 #if USING_2_1_RECENT … … 32 38 #endif 33 39 /* Default Port Hook */ 34 ap_hook_default_port(mgs_hook_default_port, NULL,NULL, APR_HOOK_MIDDLE);40 ap_hook_default_port(mgs_hook_default_port, NULL, NULL, APR_HOOK_MIDDLE); 35 41 /* Pre-Connect Hook */ 36 ap_hook_pre_connection(mgs_hook_pre_connection, NULL, NULL, APR_HOOK_MIDDLE); 42 ap_hook_pre_connection(mgs_hook_pre_connection, NULL, NULL, 43 APR_HOOK_MIDDLE); 37 44 /* Pre-Config Hook */ 38 45 ap_hook_pre_config(mgs_hook_pre_config, NULL, NULL, 39 APR_HOOK_MIDDLE);46 APR_HOOK_MIDDLE); 40 47 /* Child-Init Hook */ 41 48 ap_hook_child_init(mgs_hook_child_init, NULL, NULL, 42 APR_HOOK_MIDDLE);49 APR_HOOK_MIDDLE); 43 50 /* Authentication Hook */ 44 51 ap_hook_access_checker(mgs_hook_authz, NULL, NULL, 45 APR_HOOK_REALLY_FIRST);52 APR_HOOK_REALLY_FIRST); 46 53 /* Fixups Hook */ 47 54 ap_hook_fixups(mgs_hook_fixups, NULL, NULL, APR_HOOK_REALLY_FIRST); … … 53 60 54 61 /* Input Filter */ 55 ap_register_input_filter(GNUTLS_INPUT_FILTER_NAME, 56 mgs_filter_input, NULL,AP_FTYPE_CONNECTION + 5);62 ap_register_input_filter(GNUTLS_INPUT_FILTER_NAME, mgs_filter_input, 63 NULL, AP_FTYPE_CONNECTION + 5); 57 64 /* Output Filter */ 58 ap_register_output_filter(GNUTLS_OUTPUT_FILTER_NAME, 59 mgs_filter_output, NULL,AP_FTYPE_CONNECTION + 5);65 ap_register_output_filter(GNUTLS_OUTPUT_FILTER_NAME, mgs_filter_output, 66 NULL, AP_FTYPE_CONNECTION + 5); 60 67 61 68 /* mod_proxy calls these functions */ … … 64 71 } 65 72 66 int ssl_is_https(conn_rec *c) { 73 int ssl_is_https(conn_rec *c) 74 { 67 75 mgs_srvconf_rec *sc = (mgs_srvconf_rec *) 68 76 ap_get_module_config(c->base_server->module_config, &gnutls_module); 69 77 if(sc->enabled == 0 || sc->non_ssl_request == 1) { 70 78 /* SSL/TLS Disabled or Plain HTTP Connection Detected */ … … 75 83 } 76 84 77 int ssl_engine_disable(conn_rec *c) { 85 int ssl_engine_disable(conn_rec *c) 86 { 78 87 mgs_srvconf_rec *sc = (mgs_srvconf_rec *) 79 88 ap_get_module_config(c->base_server->module_config, &gnutls_module); 80 89 if(sc->enabled == GNUTLS_ENABLED_FALSE) { 81 90 return 1; 82 91 } 83 ap_remove_input_filter(c->input_filters); 84 ap_remove_input_filter(c->output_filters); 85 mgs_cleanup_pre_config(c->pool); 86 sc->enabled = 0; 92 93 /* disable TLS for this connection */ 94 mgs_handle_t *ctxt = (mgs_handle_t *) 95 ap_get_module_config(c->conn_config, &gnutls_module); 96 if (ctxt == NULL) 97 { 98 ctxt = apr_pcalloc(c->pool, sizeof (*ctxt)); 99 ap_set_module_config(c->conn_config, &gnutls_module, ctxt); 100 } 101 ctxt->enabled = GNUTLS_ENABLED_FALSE; 102 ctxt->is_proxy = GNUTLS_ENABLED_TRUE; 103 104 if (c->input_filters) 105 ap_remove_input_filter(c->input_filters); 106 if (c->output_filters) 107 ap_remove_output_filter(c->output_filters); 108 87 109 return 1; 88 110 } 89 111 90 int ssl_proxy_enable(conn_rec *c) { 112 int ssl_proxy_enable(conn_rec *c) 113 { 114 /* check if TLS proxy support is enabled */ 91 115 mgs_srvconf_rec *sc = (mgs_srvconf_rec *) 92 ap_get_module_config(c->base_server->module_config, &gnutls_module); 93 sc->proxy_enabled = 1; 94 sc->enabled = 0; 116 ap_get_module_config(c->base_server->module_config, &gnutls_module); 117 if (sc->proxy_enabled != GNUTLS_ENABLED_TRUE) 118 { 119 ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, c, 120 "%s: mod_proxy requested TLS proxy, but not enabled " 121 "for %s", __func__, sc->cert_cn); 122 return 0; 123 } 124 125 /* enable TLS for this connection */ 126 mgs_handle_t *ctxt = (mgs_handle_t *) 127 ap_get_module_config(c->conn_config, &gnutls_module); 128 if (ctxt == NULL) 129 { 130 ctxt = apr_pcalloc(c->pool, sizeof (*ctxt)); 131 ap_set_module_config(c->conn_config, &gnutls_module, ctxt); 132 } 133 ctxt->enabled = GNUTLS_ENABLED_TRUE; 134 ctxt->is_proxy = GNUTLS_ENABLED_TRUE; 95 135 return 1; 96 136 } 97 137 98 138 static const command_rec mgs_config_cmds[] = { 99 AP_INIT_TAKE1(" SSLProxyEngine", mgs_set_proxy_engine,139 AP_INIT_TAKE1("GnuTLSProxyEngine", mgs_set_proxy_engine, 100 140 NULL, 101 141 RSRC_CONF | OR_AUTHCFG, 102 142 "Enable SSL Proxy Engine"), 143 AP_INIT_TAKE1("GnuTLSP11Module", mgs_set_p11_module, 144 NULL, 145 RSRC_CONF, 146 "Load this additional PKCS #11 provider library"), 147 AP_INIT_RAW_ARGS("GnuTLSPIN", mgs_set_pin, 148 NULL, 149 RSRC_CONF, 150 "The PIN to use in case of encrypted keys or PKCS #11 tokens."), 151 AP_INIT_RAW_ARGS("GnuTLSSRKPIN", mgs_set_srk_pin, 152 NULL, 153 RSRC_CONF, 154 "The SRK PIN to use in case of TPM keys."), 103 155 AP_INIT_TAKE1("GnuTLSClientVerify", mgs_set_client_verify, 104 156 NULL, … … 181 233 "Whether this server has GnuTLS Enabled. Default: Off"), 182 234 AP_INIT_TAKE1("GnuTLSExportCertificates", 183 mgs_set_export_certificates_enabled, 184 NULL, 185 RSRC_CONF, 186 "Whether to export PEM encoded certificates to CGIs. Default: Off"), 235 mgs_set_export_certificates_size, 236 NULL, 237 RSRC_CONF, 238 "Max size to export PEM encoded certificates to CGIs (or off to disable). Default: off"), 239 AP_INIT_TAKE1("GnuTLSProxyKeyFile", mgs_store_cred_path, 240 NULL, 241 RSRC_CONF, 242 "X509 client private file for proxy connections"), 243 AP_INIT_TAKE1("GnuTLSProxyCertificateFile", mgs_store_cred_path, 244 NULL, 245 RSRC_CONF, 246 "X509 client certificate file for proxy connections"), 247 AP_INIT_TAKE1("GnuTLSProxyCAFile", mgs_store_cred_path, 248 NULL, 249 RSRC_CONF, 250 "X509 trusted CA file for proxy connections"), 251 AP_INIT_TAKE1("GnuTLSProxyCRLFile", mgs_store_cred_path, 252 NULL, 253 RSRC_CONF, 254 "X509 CRL file for proxy connections"), 255 AP_INIT_RAW_ARGS("GnuTLSProxyPriorities", mgs_set_priorities, 256 NULL, 257 RSRC_CONF, 258 "The priorities to enable for proxy connections (ciphers, key exchange, " 259 "MACs, compression)."), 187 260 { NULL }, 188 261 };
Note: See TracChangeset
for help on using the changeset viewer.