TSSSLCLIENTCONTEXT(3ts)
π TSSSLCLIENTCONTEXT π
okay bestie, welcome to TSSSLCLIENTCONTEXT(3ts) from the Apache Traffic Server manual β yes she's a section-3 library page and yes she's serving looks β¨
πΈ NAME πΈ
TSSslClientContext β the TSSslClientContext API function, periodt π
π SYNOPSIS π
#include <ts/ts.h>
TSReturnCode TSSslClientContextsNamesGet(int n, const char **result, int *actual)
TSSslContext TSSslClientContextFindByName(const char *ca_paths, const char *ck_paths)
π¦ DESCRIPTION π¦
so these functions are literally your little backstage pass to peek at the client contexts that Traffic Server uses to connect to upstreams π
TSSslClientContextsNamesGet() is the one you call when you wanna grab the entire client context mapping. and here's the tea: in Traffic Server, client contexts are stored in a 2-level mapping, with ca paths and cert/key paths as the keys ππ so basically every 2 null-terminated strings inside result can be used to look up exactly one context.
result points to a user-allocated array that's gonna hold pointers to lookup key strings, and n is the size of that result array. and actual, if it's valid, gets filled with the actual number of lookup keys β that's 2 for each context babe, do the math β¨
TSSslClientContextFindByName() is the follow-up bestie. she retrieves the client context pointed to by the lookup key pairs. but listen β you should call TSSslClientContextsNamesGet() first to figure out which lookup keys are even present before you go querying for the context, iykyk. ca_paths should be the first key and ck_paths should be the second.
π heads up: this function returns NULL if the client context mapping got changed and no valid context exists for that key pair. rude but fair.
and also β the caller is responsible for releasing the context returned by this function, using TSSslContextDestroy(). don't be the friend who leaves the context hanging, it's giving leak π
π EXAMPLES π
the example below is excerpted from example/plugins/c-api/client_context_dump/client_context_dump.cc in the Traffic Server source distribution π she demonstrates how to use TSSslClientContextsNamesGet() and TSSslClientContextFindByName() to retrieve all contexts π«Ά
if (tag.substr(0, PLUGIN_PREFIX.size()) == PLUGIN_PREFIX) {
tag.remove_prefix(PLUGIN_PREFIX.size());
// Grab all keys by API and dump to log file according to arg passed in
int count = 0;
TSSslClientContextsNamesGet(0, nullptr, &count);
if (count > 0) {
char const **results = static_cast<char const **>(malloc(sizeof(const char *) * count));
TSSslClientContextsNamesGet(count, results, nullptr);
for (int i = 0; i < count; i += 2) {
dump_context(results[i], results[i + 1]);
}
}
}
void
dump_context(const char *ca_path, const char *ck_path)
{
TSSslContext ctx = TSSslClientContextFindByName(ca_path, ck_path);
if (ctx) {
π COPYRIGHT π
2026, dev@trafficserver.apache.org
okay that's the whole page, no notes π she's giving version 9.2, dated Feb 12, 2026, brought to you by the Apache Traffic Server girlies β slay, and remember to TSSslContextDestroy() your contexts before you log off, mwah πβ¨π¦
π¦ where this page comes from
- ubuntu noble: trafficserver-dev 9.2.3+ds-1+deb12u1ubuntu0.1 Β· Apache-2.0
- ubuntu questing: trafficserver-dev 9.2.5+ds-1ubuntu2.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms