1.. Licensed to the Apache Software Foundation (ASF) under one 2 or more contributor license agreements. See the NOTICE file 3 distributed with this work for additional information 4 regarding copyright ownership. The ASF licenses this file 5 to you under the Apache License, Version 2.0 (the 6 "License"); you may not use this file except in compliance 7 with the License. You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, 12 software distributed under the License is distributed on an 13 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 KIND, either express or implied. See the License for the 15 specific language governing permissions and limitations 16 under the License. 17 18.. include:: ../../../common.defs 19.. default-domain:: c 20 21TSSslSession 22************ 23 24Synopsis 25======== 26 27.. code-block:: cpp 28 29 #include <ts/ts.h> 30 31.. function:: TSSslSession TSSslSessionGet(const TSSslSessionID * sessionid) 32.. function:: int TSSslSessionGetBuffer(const TSSslSessionID * sessionid, char * buffer, int * len_ptr) 33.. function:: TSReturnCode TSSslSessionInsert(const TSSslSessionID * sessionid, TSSslSession addSession, TSSslConnection ssl_conn) 34.. function:: TSReturnCode TSSslSessionRemove(const TSSslSessionID * sessionid) 35.. function:: void TSSslTicketKeyUpdate(char * ticketData, int ticketDataLength) 36 37Description 38=========== 39 40These functions work with the internal ATS session cache. These functions are only useful if the ATS internal 41session cache is enabled by setting :ts:cv:`proxy.config.ssl.session_cache` has been set to 2. 42 43These functions tend to be used with the :macro:`TS_SSL_SESSION_HOOK`. 44 45The functions work with the :type:`TSSslSessionID` object to identify sessions to retrieve, insert, or delete. 46 47The functions also work with the :type:`TSSslSession` object which can be cast to a pointer to the openssl SSL_SESSION object. 48 49These functions perform the appropriate locking on the session cache to avoid errors. 50 51The :func:`TSSslSessionGet` and :func:`TSSslSessionGetBuffer` functions retrieve the :type:`TSSslSession` object that is identified by the 52:type:`TSSslSessionID` object. If there is no matching session object, :func:`TSSslSessionGet` returns NULL and :func:`TSSslSessionGetBuffer` 53returns 0. 54 55:func:`TSSslSessionGetBuffer` returns the session information serialized in a buffer that can be shared between processes. 56When the function is called len_ptr should point to the amount of space 57available in the buffer parameter. The function returns the amount of data really needed to encode the session. len_ptr is 58updated with the amount of data actually stored in the buffer. 59:func:`TSSslSessionGetBuffer` will not overrun the provided buffer, but the caller should ensure that the data's size was not larger 60than the buffer by comparing the returned value with the value of len_ptr. If the returned value is larger than the buffer size, 61then the session data did not fit in the buffer and the session data stored in the buffer output variable should not be used. 62 63 64:func:`TSSslSessionInsert` inserts the session specified by the addSession parameter into the ATS session cache under the sessionid key. 65If there is already an entry in the cache for the session id key, it is first removed before the new entry is added. 66 67:func:`TSSslSessionRemove` removes the session entry from the session cache that is keyed by sessionid. 68 69:func:`TSSslTicketKeyUpdate` updates the running ATS process to use a new set of Session Ticket Encryption keys. This behaves the same way as 70updating the session ticket encrypt key file with new data and reloading the current ATS process. However, this API does not 71require writing session ticket encryption keys to disk. 72 73If both the ticket key files and :func:`TSSslTicketKeyUpdate` are used to update session ticket encryption keys, ATS will use the 74most recent update regardless if whether it was made by file and configuration reload or API. 75