bryancall commented on code in PR #13711:
URL: https://github.com/apache/trafficserver/pull/13711#discussion_r4077169876


##########
src/iocore/net/SSLConfig.cc:
##########
@@ -463,9 +464,12 @@ SSLConfigParams::initialize(ConfigContext ctx)
   // SSL session cache configurations
   ssl_origin_session_cache      = 
RecGetRecordInt("proxy.config.ssl.origin_session_cache.enabled").value_or(0);
   ssl_origin_session_cache_size = 
RecGetRecordInt("proxy.config.ssl.origin_session_cache.size").value_or(0);
+  ssl_origin_session_max_size =
+    
RecGetRecordInt("proxy.config.ssl.origin_session_cache.max_session_size").value_or(SSL_DEFAULT_MAX_ORIG_SESSION_SIZE);

Review Comment:
   **Fixed in a3774a6.** You were right that the record layer could not be 
trusted for this one. `initialize_record()` registers the value from 
`RecConfigOverrideFromEnvironment()` without running `RecordValidityCheck()`, 
so the environment path reached the assignment unbounded and `-1` became 
`SIZE_MAX` — which defeats the only thing keeping `SSLSessionDup()`'s 
serialization buffer inside the event thread stack.
   
   Now clamped to the documented range at the assignment in `SSLConfig.cc`, 
with a `Warning()` naming the configured value and what it was clamped to. The 
bounds moved onto `SSLConfigParams` as `static constexpr` members, so the 
config that owns the record owns its limits rather than reaching for a macro in 
`SSLSessionCache.h`.



##########
tests/gold_tests/tls/tls_origin_session_reuse_large.test.py:
##########
@@ -0,0 +1,143 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.Summary = '''
+Origin TLS sessions must still be cached when the serialized session is large.
+
+The origin session cache refuses to store a session whose i2d_SSL_SESSION form
+exceeds SSL_MAX_ORIG_SESSION_SIZE.  A serialized session carries the peer
+certificate and the session ticket, so an origin with a large certificate -- or
+any mutual-TLS origin, whose ticket encodes the client certificate -- produces 
a
+session that trips that limit and is silently dropped, costing a full handshake
+on every connection.
+'''
+
+# ts_origin presents a deliberately large certificate (120 SANs, 4328 bytes 
DER),
+# so the session ts_proxy caches for it does not fit in a small fixed buffer.
+ts_origin = Test.MakeATSProcess("ts_origin", enable_tls=True)
+ts_proxy = Test.MakeATSProcess("ts_proxy", enable_tls=True)
+server = Test.MakeOriginServer("server")
+
+request_header = {"headers": "GET / HTTP/1.1\r\nHost: 
www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
+response_header = {
+    "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n",
+    "timestamp": "1469733493.993",
+    "body": "large session test"
+}
+server.addResponse("sessionlog.json", request_header, response_header)
+
+ts_origin.addSSLfile("ssl/server-large.pem")
+ts_origin.addSSLfile("ssl/server-large.key")
+ts_proxy.addSSLfile("ssl/server.pem")
+ts_proxy.addSSLfile("ssl/server.key")
+

Review Comment:
   **Fixed in a3774a6.** Restructured as `OriginSessionCeilingTest`, following 
`tests/gold_tests/ats_probe` — one class, typed attributes, a method per 
process, and docstrings with `:param:`/`:return:`. The two cases now share one 
configured origin instead of duplicating the setup. Thanks for the pointer to a 
current example.



##########
src/iocore/net/P_SSLConfig.h:
##########
@@ -73,6 +73,7 @@ struct SSLConfigParams : public ConfigInfo {
   int   verify_depth;
   int   ssl_origin_session_cache{0};
   int   ssl_origin_session_cache_size{0};
+  int   ssl_origin_session_max_size{0};

Review Comment:
   **Fixed in a3774a6.** `ssl_origin_session_max_size` is now `size_t`, 
matching the static it publishes into. It landed together with the clamp for 
@bneradt's P2, since enforcing the range at the assignment is what makes the 
unsigned type unambiguously correct here.



##########
src/iocore/net/P_SSLConfig.h:
##########
@@ -73,6 +73,7 @@ struct SSLConfigParams : public ConfigInfo {
   int   verify_depth;
   int   ssl_origin_session_cache{0};
   int   ssl_origin_session_cache_size{0};
+  int   ssl_origin_session_max_size{0};

Review Comment:
   **Fixed in a3774a6.** Same change as the duplicate of this thread — stored 
as `size_t` now, with the conversion and the range check done once at the 
assignment.



##########
src/iocore/net/SSLConfig.cc:
##########
@@ -70,6 +70,7 @@ char              *SSLConfigParams::ssl_ocsp_user_agent       
       = nullptr;
 int                SSLConfigParams::ssl_handshake_timeout_in         = 0;
 int                SSLConfigParams::origin_session_cache             = 1;
 size_t             SSLConfigParams::origin_session_cache_size        = 10240;
+size_t             SSLConfigParams::origin_session_max_size          = 
SSL_DEFAULT_MAX_ORIG_SESSION_SIZE;

Review Comment:
   **Fixed in a3774a6.** Agreed. The default is now 
`SSLConfigParams::ORIGIN_SESSION_MAX_SIZE_DEFAULT`, a `static constexpr 
size_t`, alongside `_MIN` and `_MAX` for the range the clamp enforces. 
`SSLConfig.cc` no longer depends on a macro from `SSLSessionCache.h`.



##########
tests/gold_tests/tls/tls_origin_session_reuse_large.test.py:
##########
@@ -0,0 +1,145 @@
+'''
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.Summary = '''
+Origin TLS sessions must still be cached when the serialized session is large.
+
+The origin session cache refuses to store a session whose i2d_SSL_SESSION form
+exceeds SSL_MAX_ORIG_SESSION_SIZE.  A serialized session carries the peer
+certificate and the session ticket, so an origin with a large certificate -- or
+any mutual-TLS origin, whose ticket encodes the client certificate -- produces 
a

Review Comment:
   **Fixed in a3774a6.** The summary described a fixed 
`SSL_MAX_ORIG_SESSION_SIZE` that this PR removes. It now describes the 
configurable ceiling, and the class docstring explains why a mutual-TLS origin 
lands above the old 4096 — the ticket has to encode the client certificate to 
resume the authenticated session.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to