Skip to content

Commit 78b8ff8

Browse files
committed
proxy.config.ssl.session_cache.mode
In the 10.0.0 release, we renamed proxy.config.ssl.session_cache.enabled to proxy.config.ssl.session_cache.value because enabled seemed incorrect for a configuration that took a non-boolean enumeration of values. We accidentially left the documentation describing proxy.config.ssl.session_cache.enabled, however. In discussion about this, we decided to rename such configurations to "mode" instead of value. Another issue (#12412) records making these renames for 11.0.0. This PR just addresses the current issues with proxy.config.ssl.session_cache.enabled by: * Adding implementation support for proxy.config.ssl.session_cache.enabled since we documented that already but document it as deprecated. * Keep implementation support for proxy.config.ssl.session_cache.value since users might be using that. * Add proxy.config.ssl.session_cache.mode as the preferred new mode. The user can set values for any of these via: * implicit default config values, * plugin default values via TSMgmtIntCreate, * explicit records.yaml values, or * override via environment variable. It will probably be a very rare user that implements any of these across values, but in case they do, this patch implements a selection of the finally chosen config value based on a priority base of the above, with "mode" valued over "value" valued over "enabled". Fixes: 11901
1 parent 447a2a0 commit 78b8ff8

File tree

15 files changed

+123
-32
lines changed

15 files changed

+123
-32
lines changed

doc/admin-guide/files/records.yaml.en.rst

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,9 +3958,9 @@ SSL Termination
39583958
Setting a value less than or equal to ``0`` effectively disables
39593959
SSL session cache for the origin server.
39603960

3961-
.. ts:cv:: CONFIG proxy.config.ssl.session_cache.enabled INT 2
3961+
.. ts:cv:: CONFIG proxy.config.ssl.session_cache.mode INT 2
39623962
3963-
Enables the SSL session cache:
3963+
Sets the SSL session cache mode:
39643964

39653965
===== ======================================================================
39663966
Value Description
@@ -3972,13 +3972,22 @@ SSL Termination
39723972
implementation.
39733973
===== ======================================================================
39743974

3975+
.. ts:cv:: CONFIG proxy.config.ssl.session_cache.enabled INT 2
3976+
3977+
.. deprecated:: 10.1.0
3978+
Use :ts:cv:`proxy.config.ssl.session_cache.mode` instead.
3979+
3980+
This configuration exists for historical reasons and is deprecated in favor of
3981+
:ts:cv:`proxy.config.ssl.session_cache.mode`. It accepts the same values and
3982+
has identical behavior, so see that documentation for details.
3983+
39753984
.. ts:cv:: CONFIG proxy.config.ssl.session_cache.timeout INT 0
39763985
39773986
This configuration specifies the lifetime of SSL session cache
39783987
entries in seconds. If it is ``0``, then the SSL library will use
39793988
a default value, typically 300 seconds. Note: This option has no affect
39803989
when using the |TS| session cache (option ``2`` in
3981-
``proxy.config.ssl.session_cache.enabled``)
3990+
``proxy.config.ssl.session_cache.mode``)
39823991

39833992
See :ref:`admin-performance-timeouts` for more discussion on |TS| timeouts.
39843993

@@ -4020,9 +4029,9 @@ SSL Termination
40204029
Take into account that setting the value to 0 will disable session caching for TLSv1.3
40214030
connections.
40224031

4023-
Lowering this setting to ``1`` can be interesting when ``proxy.config.ssl.session_cache.enabled`` is enabled because
4032+
Lowering this setting to ``1`` can be interesting when ``proxy.config.ssl.session_cache.mode`` is enabled because
40244033
otherwise for every new TLSv1.3 connection two session IDs will be inserted in the session cache.
4025-
On the other hand, if ``proxy.config.ssl.session_cache.enabled`` is disabled, using the default value is recommended.
4034+
On the other hand, if ``proxy.config.ssl.session_cache.mode`` is disabled, using the default value is recommended.
40264035
In those scenarios, increasing the number of tickets could be potentially beneficial for clients performing
40274036
multiple requests over concurrent TLS connections as per RFC 8446 clients SHOULDN'T reuse TLS Tickets.
40284037

doc/admin-guide/performance/index.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ SSL-Specific Options
528528
~~~~~~~~~~~~~~~~~~~~
529529

530530
:ts:cv:`proxy.config.ssl.max_record_size`
531-
:ts:cv:`proxy.config.ssl.session_cache.enabled`
531+
:ts:cv:`proxy.config.ssl.session_cache.mode`
532532
:ts:cv:`proxy.config.ssl.session_cache.size`
533533

534534
Thread Types

doc/admin-guide/tools/converting-records-to-yaml.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Converting a file with a detailed output.
158158
├──» #5 : proxy.config.ssl.TLSv1_3 -> proxy.config.ssl.TLSv1_3.enabled
159159
├──» #6 : proxy.config.ssl.client.TLSv1_3 -> proxy.config.ssl.client.TLSv1_3.enabled
160160
├──» #7 : proxy.config.ssl.origin_session_cache -> proxy.config.ssl.origin_session_cache.enabled
161-
└──» #8 : proxy.config.ssl.session_cache -> proxy.config.ssl.session_cache.value
161+
└──» #8 : proxy.config.ssl.session_cache -> proxy.config.ssl.session_cache.mode
162162
163163
164164
There are a few things to note here:

doc/developer-guide/api/functions/TSSslSession.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Description
3838
===========
3939

4040
These functions work with the internal ATS session cache. These functions are only useful if the ATS internal
41-
session cache is enabled by setting :ts:cv:`proxy.config.ssl.session_cache.enabled` has been set to 2.
41+
session cache is enabled by setting :ts:cv:`proxy.config.ssl.session_cache.mode` has been set to 2.
4242

4343
These functions tend to be used with the :enumerator:`TS_SSL_SESSION_HOOK`.
4444

doc/developer-guide/plugins/hooks-and-transactions/ssl-session-api.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ to enable the plugin to update the session cache based on outside information, e
3131

3232
This hook is invoked when a change has been made to the ATS session cache or a session has been accessed
3333
from ATS via OpenSSL. These hooks are only activated if the ATS implementation of the session cache is in
34-
use. This means :ts:cv:`proxy.config.ssl.session_cache.enabled` has been set to 2.
34+
use. This means :ts:cv:`proxy.config.ssl.session_cache.mode` has been set to 2.
3535

3636
The hook callback has the following signature
3737

doc/release-notes/upgrading.en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ The following :file:`records.yaml` changes have been made:
172172
- The records.yaml entry ``proxy.config.exec_thread.autoconfig`` has been renamed to :ts:cv:`proxy.config.exec_thread.autoconfig.enabled`.
173173
- The records.yaml entry ``proxy.config.tunnel.prewarm`` has been renamed to :ts:cv:`proxy.config.tunnel.prewarm.enabled`.
174174
- The records.yaml entry ``proxy.config.ssl.origin_session_cache`` has been renamed to :ts:cv:`proxy.config.ssl.origin_session_cache.enabled`.
175-
- The records.yaml entry ``proxy.config.ssl.session_cache`` has been renamed to :ts:cv:`proxy.config.ssl.session_cache.enabled`.
175+
- The records.yaml entry ``proxy.config.ssl.session_cache`` has been renamed to :ts:cv:`proxy.config.ssl.session_cache.mode`.
176176
- The records.yaml entry ``proxy.config.ssl.TLSv1_3`` has been renamed to :ts:cv:`proxy.config.ssl.TLSv1_3.enabled`.
177177
- The records.yaml entry ``proxy.config.ssl.client.TLSv1_3`` has been renamed to :ts:cv:`proxy.config.ssl.client.TLSv1_3.enabled`.
178178
- The records.yaml entry :ts:cv:`proxy.config.allocator.iobuf_chunk_sizes` has been added

include/records/RecDefs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ enum RecCheckT {
115115
/// @internal @c REC_SOURCE_NULL is useful for a return value, I don't see using it in the actual data.
116116
/// @internal If this is changed, TSMgmtSource in apidefs.h.in must also be changed.
117117
enum RecSourceT {
118-
REC_SOURCE_NULL, ///< No source / value not set.
119-
REC_SOURCE_DEFAULT, ///< Built in default.
120-
REC_SOURCE_PLUGIN, ///< Plugin supplied default.
118+
REC_SOURCE_NULL, ///< No source / value not set. Not used in the actual data.
119+
REC_SOURCE_DEFAULT, ///< Built in records.yaml default.
120+
REC_SOURCE_PLUGIN, ///< Plugin supplied default. See TSMgmtIntCreate/TSMgmtStringCreate.
121121
REC_SOURCE_EXPLICIT, ///< Set by administrator (config file, external API, etc.)
122-
REC_SOURCE_ENV ///< Process environment variable.
122+
REC_SOURCE_ENV ///< Process environment variable override.
123123
};
124124

125125
enum RecAccessT {

src/iocore/net/SSLConfig.cc

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@
4242
#include "tscore/ink_config.h"
4343
#include "tscore/Layout.h"
4444
#include "records/RecHttp.h"
45+
#include "records/RecCore.h"
4546

4647
#include <openssl/pem.h>
48+
#include <array>
4749
#include <cstring>
4850
#include <cmath>
51+
#include <unordered_map>
4952

5053
int SSLConfig::config_index = 0;
5154
int SSLConfig::configids[] = {0, 0};
@@ -89,6 +92,80 @@ DbgCtl dbg_ctl_ssl_client_ctx{"ssl_client_ctx"};
8992

9093
} // end anonymous namespace
9194

95+
/** Determines the SSL session cache configuration value using a priority-based selection scheme.
96+
*
97+
* This function resolves the SSL session cache configuration by evaluating multiple potential
98+
* configuration sources and selecting the one with the highest priority. The priority calculation
99+
* combines two factors:
100+
*
101+
* Configuration Name Priority (base priority):
102+
* - `proxy.config.ssl.session_cache.mode`: 3 (highest preference)
103+
* - `proxy.config.ssl.session_cache.value`: 2 (medium preference)
104+
* - `proxy.config.ssl.session_cache.enabled`: 1 (lowest preference)
105+
*
106+
* Configuration Source Priority (added to base priority):
107+
* - Environment variable (`REC_SOURCE_ENV`): +0x30 (highest precedence)
108+
* - Explicit configuration (`REC_SOURCE_EXPLICIT`): +0x20 (config file, API)
109+
* - Plugin default (`REC_SOURCE_PLUGIN`): +0x10 (plugin-supplied)
110+
* - Built-in default (`REC_SOURCE_DEFAULT`): +0x00 (lowest precedence)
111+
*
112+
* Priority Calculation:
113+
* `total_priority = base_priority + source_priority`
114+
*
115+
* Examples:
116+
* - `mode` set via environment variable: 3 + 0x30 = 0x33 (highest possible)
117+
* - `mode` set explicitly in config: 3 + 0x20 = 0x23
118+
* - `value` set via environment variable: 2 + 0x30 = 0x32
119+
* - `enabled` set explicitly in config: 1 + 0x20 = 0x21
120+
*
121+
* The configuration with the highest total priority is selected. This ensures that:
122+
* 1. Environment variables always override other sources.
123+
* 2. Among configurations from the same source, `mode` > `value` > `enabled`.
124+
* 3. Explicit configuration overrides plugin defaults and built-in defaults.
125+
*
126+
* @return The SSL session cache mode value.
127+
*/
128+
static int
129+
get_ssl_session_cache_config()
130+
{
131+
struct ConfigOption {
132+
const char *name; ///< Configuration parameter name (e.g., "proxy.config.ssl.session_cache.mode").
133+
int value; ///< The configured value if explicitly set.
134+
int priority; ///< The inherit priority of the config name, higher is more preferred.
135+
};
136+
137+
/// The priority of the source. Higher is more preferred.
138+
std::unordered_map<int, int> source_priorities = {
139+
{REC_SOURCE_ENV, 0x30},
140+
{REC_SOURCE_EXPLICIT, 0x20},
141+
{REC_SOURCE_PLUGIN, 0x10},
142+
{REC_SOURCE_DEFAULT, 0x0 },
143+
{REC_SOURCE_NULL, 0x0 }, // For completeness, no record should have this set.
144+
};
145+
146+
std::array<ConfigOption, 3> configs = {
147+
{
148+
{"proxy.config.ssl.session_cache.mode", 0, 0x3},
149+
{"proxy.config.ssl.session_cache.value", 0, 0x2},
150+
{"proxy.config.ssl.session_cache.enabled", 0, 0x1},
151+
}
152+
};
153+
154+
// Loop over the config names, updating their priority score per their source.
155+
auto *highest_priority_config = &configs[0];
156+
for (auto &config : configs) {
157+
RecSourceT source;
158+
if (RecGetRecordSource(config.name, &source) == REC_ERR_OKAY) {
159+
config.priority += source_priorities[source];
160+
config.value = RecGetRecordInt(config.name).value_or(0);
161+
if (config.priority > highest_priority_config->priority) {
162+
highest_priority_config = &config;
163+
}
164+
}
165+
}
166+
return highest_priority_config->value;
167+
}
168+
92169
SSLConfigParams::SSLConfigParams()
93170
{
94171
ink_mutex_init(&ctxMapLock);
@@ -452,7 +529,8 @@ SSLConfigParams::initialize()
452529
// SSL session cache configurations
453530
ssl_origin_session_cache = RecGetRecordInt("proxy.config.ssl.origin_session_cache.enabled").value_or(0);
454531
ssl_origin_session_cache_size = RecGetRecordInt("proxy.config.ssl.origin_session_cache.size").value_or(0);
455-
ssl_session_cache = RecGetRecordInt("proxy.config.ssl.session_cache.value").value_or(0);
532+
ssl_session_cache = get_ssl_session_cache_config();
533+
456534
ssl_session_cache_size = RecGetRecordInt("proxy.config.ssl.session_cache.size").value_or(0);
457535
ssl_session_cache_num_buckets = RecGetRecordInt("proxy.config.ssl.session_cache.num_buckets").value_or(0);
458536
ssl_session_cache_skip_on_contention =

src/records/RecordsConfig.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,11 @@ static const RecordElement RecordsConfig[] =
11931193
,
11941194
{RECT_CONFIG, "proxy.config.ssl.origin_session_cache.size", RECD_INT, "10240", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
11951195
,
1196-
{RECT_CONFIG, "proxy.config.ssl.session_cache.value", RECD_INT, "2", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
1196+
{RECT_CONFIG, "proxy.config.ssl.session_cache.mode", RECD_INT, "2", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
1197+
,
1198+
{RECT_CONFIG, "proxy.config.ssl.session_cache.enabled", RECD_INT, "2", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
1199+
,
1200+
{RECT_CONFIG, "proxy.config.ssl.session_cache.value", RECD_INT, "2", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
11971201
,
11981202
{RECT_CONFIG, "proxy.config.ssl.session_cache.size", RECD_INT, "102400", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
11991203
,

tests/gold_tests/pluginTest/stek_share/stek_share.test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
'proxy.config.exec_thread.limit': 4,
165165
'proxy.config.ssl.server.cert.path': '{0}'.format(Test.RunDirectory),
166166
'proxy.config.ssl.server.private_key.path': '{0}'.format(Test.RunDirectory),
167-
'proxy.config.ssl.session_cache.value': 2,
167+
'proxy.config.ssl.session_cache.mode': 2,
168168
'proxy.config.ssl.session_cache.size': 1024,
169169
'proxy.config.ssl.session_cache.timeout': 7200,
170170
'proxy.config.ssl.session_cache.num_buckets': 16,
@@ -184,7 +184,7 @@
184184
'proxy.config.exec_thread.limit': 4,
185185
'proxy.config.ssl.server.cert.path': '{0}'.format(Test.RunDirectory),
186186
'proxy.config.ssl.server.private_key.path': '{0}'.format(Test.RunDirectory),
187-
'proxy.config.ssl.session_cache.value': 2,
187+
'proxy.config.ssl.session_cache.mode': 2,
188188
'proxy.config.ssl.session_cache.size': 1024,
189189
'proxy.config.ssl.session_cache.timeout': 7200,
190190
'proxy.config.ssl.session_cache.num_buckets': 16,
@@ -204,7 +204,7 @@
204204
'proxy.config.exec_thread.limit': 4,
205205
'proxy.config.ssl.server.cert.path': '{0}'.format(Test.RunDirectory),
206206
'proxy.config.ssl.server.private_key.path': '{0}'.format(Test.RunDirectory),
207-
'proxy.config.ssl.session_cache.value': 2,
207+
'proxy.config.ssl.session_cache.mode': 2,
208208
'proxy.config.ssl.session_cache.size': 1024,
209209
'proxy.config.ssl.session_cache.timeout': 7200,
210210
'proxy.config.ssl.session_cache.num_buckets': 16,
@@ -224,7 +224,7 @@
224224
'proxy.config.exec_thread.limit': 4,
225225
'proxy.config.ssl.server.cert.path': '{0}'.format(Test.RunDirectory),
226226
'proxy.config.ssl.server.private_key.path': '{0}'.format(Test.RunDirectory),
227-
'proxy.config.ssl.session_cache.value': 2,
227+
'proxy.config.ssl.session_cache.mode': 2,
228228
'proxy.config.ssl.session_cache.size': 1024,
229229
'proxy.config.ssl.session_cache.timeout': 7200,
230230
'proxy.config.ssl.session_cache.num_buckets': 16,
@@ -244,7 +244,7 @@
244244
'proxy.config.exec_thread.limit': 4,
245245
'proxy.config.ssl.server.cert.path': '{0}'.format(Test.RunDirectory),
246246
'proxy.config.ssl.server.private_key.path': '{0}'.format(Test.RunDirectory),
247-
'proxy.config.ssl.session_cache.value': 2,
247+
'proxy.config.ssl.session_cache.mode': 2,
248248
'proxy.config.ssl.session_cache.size': 1024,
249249
'proxy.config.ssl.session_cache.timeout': 7200,
250250
'proxy.config.ssl.session_cache.num_buckets': 16,

0 commit comments

Comments
 (0)