MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / RM_GetClientCertificate

Function RM_GetClientCertificate

src/module.cpp:6820–6831  ·  view source on GitHub ↗

Return the X.509 client-side certificate used by the client to authenticate * this connection. * * The return value is an allocated RedisModuleString that is a X.509 certificate * encoded in PEM (Base64) format. It should be freed (or auto-freed) by the caller. * * A NULL value is returned in the following conditions: * * - Connection ID does not exist * - Connection is not a TLS connecti

Source from the content-addressed store, hash-verified

6818 * - Connection is a TLS connection but no client ceritifcate was used
6819 */
6820RedisModuleString *RM_GetClientCertificate(RedisModuleCtx *ctx, uint64_t client_id) {
6821 client *c = lookupClientByID(client_id);
6822 if (c == NULL) return NULL;
6823
6824 sds cert = connTLSGetPeerCert(c->conn);
6825 if (!cert) return NULL;
6826
6827 RedisModuleString *s = createObject(OBJ_STRING, cert);
6828 if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, s);
6829
6830 return s;
6831}
6832
6833/* --------------------------------------------------------------------------
6834 * ## Modules Dictionary API

Callers

nothing calls this directly

Calls 4

lookupClientByIDFunction · 0.85
connTLSGetPeerCertFunction · 0.85
createObjectFunction · 0.85
autoMemoryAddFunction · 0.85

Tested by

no test coverage detected