TSSSLSESSION(3ts)

πŸ“¦
version 9.2.5 Β· 4 versions
, in ubuntu noble, ubuntu questing

πŸ’– TSSslSession β€” the ATS session cache API, bestie edition πŸ’–

okay so you found the TSSslSession(3ts) page, which means you're messing with the Apache Traffic Server plugin C API and you want to poke at the internal SSL session cache. Say less. I got you. ✨


🌸 NAME 🌸

TSSslSession β€” the TSSslSession API function. That's it, that's the name, no notes. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <ts/ts.h>

TSSslSession TSSslSessionGet(const TSSslSessionID *sessionid)

int TSSslSessionGetBuffer(const TSSslSessionID *sessionid, char *buffer,
int *len_ptr)

TSReturnCode TSSslSessionInsert(const TSSslSessionID *sessionid,
TSSslSession addSession, TSSslConnection ssl_conn)

TSReturnCode TSSslSessionRemove(const TSSslSessionID *sessionid)

void TSSslTicketKeyUpdate(char *ticketData, int ticketDataLength)

look at all those little signatures, so organized, so iconic. πŸŽ€


πŸ‘‘ DESCRIPTION πŸ‘‘

so these functions are your backstage pass to the internal ATS session cache. 🫢

⚠️ real talk: these are only useful if the ATS internal session cache is actually turned on, which happens when proxy.config.ssl.session_cache has been set to 2. If you didn't set that, bestie, there is nothing here for you. πŸ’€

these functions tend to be used with the TS_SSL_SESSION_HOOK. iykyk. πŸ”₯

the whole squad works with the TSSslSessionID object to figure out which sessions to retrieve, insert, or delete. it's giving little name tag energy.

they also work with the TSSslSession object, which β€” plot twist β€” can be cast to a pointer to the OpenSSL SSL_SESSION object. 🌈

and here's the part that makes me feral: these functions perform the appropriate locking on the session cache so you don't get errors. no manual locking arc, we love that for us. πŸ˜­πŸ’–


✨ the getters ✨

TSSslSessionGet() and TSSslSessionGetBuffer() retrieve the TSSslSession object identified by the TSSslSessionID object.

if there is no matching session object:

  • TSSslSessionGet() returns NULL
  • TSSslSessionGetBuffer() returns 0

no match, no session, moving on. πŸ’…


πŸŽ€ TSSslSessionGetBuffer() and its little buffer situation πŸŽ€

this one returns the session information serialized in a buffer that can be shared between processes. cross-process slay. πŸ¦‹

when you call it, len_ptr should point to the amount of space available in the buffer parameter.

the function returns the amount of data really needed to encode the session. then len_ptr gets updated with the amount of data actually stored in the buffer.

⚠️ okay listen carefully because this is the part people mess up: TSSslSessionGetBuffer() will not overrun the buffer you gave it β€” good behavior, no cap β€” but you still need to check whether the data fit by comparing the returned value against the value of len_ptr. if the returned value is larger than the buffer size, then the session data did not fit in the buffer, and the session data stored in the buffer output variable should not be used. do not use it. i'm serious. don't. πŸ’€

πŸ’œ TSSslSessionInsert() πŸ’œ

inserts the session specified by the addSession parameter into the ATS session cache under the sessionid key.

and if there's already an entry in the cache for that session id key? it gets removed first, before the new entry is added. out with the old, in with the new, main character energy. πŸ‘‘


πŸ“ TSSslSessionRemove() πŸ“

removes the session entry from the session cache that is keyed by sessionid. bye bestie, blocked, deleted. πŸ™ˆ


🌟 TSSslTicketKeyUpdate() 🌟

updates the running ATS process to use a new set of Session Ticket Encryption keys.

this behaves the same way as updating the session ticket encrypt key file with new data and reloading the current ATS process. same vibe, same result. ✨

however β€” and this is the cute part β€” this API does not require writing session ticket encryption keys to disk. no disk, no problem. πŸ’…

and if both the ticket key files and TSSslTicketKeyUpdate() are used to update session ticket encryption keys, ATS will use the most recent update, regardless of whether it was made by file and configuration reload, or by API. whoever updated last wins, periodt. πŸ”₯


2026, dev@trafficserver.apache.org πŸ’–


and that's the whole page, bestie β€” every flag, every signature, every buffer warning, all of it preserved, none of it skipped. you understood the assignment. 🫢

this was Apache Traffic Server 9.2, dated Feb 12, 2026 β€” go forth and cache those sessions responsibly. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from