MCPcopy Create free account
hub / github.com/F-Stack/f-stack / RM_GetClientCertificate

Function RM_GetClientCertificate

app/redis-6.2.6/src/module.c:6628–6639  ·  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

6626 * - Connection is a TLS connection but no client ceritifcate was used
6627 */
6628RedisModuleString *RM_GetClientCertificate(RedisModuleCtx *ctx, uint64_t client_id) {
6629 client *c = lookupClientByID(client_id);
6630 if (c == NULL) return NULL;
6631
6632 sds cert = connTLSGetPeerCert(c->conn);
6633 if (!cert) return NULL;
6634
6635 RedisModuleString *s = createObject(OBJ_STRING, cert);
6636 if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, s);
6637
6638 return s;
6639}
6640
6641/* --------------------------------------------------------------------------
6642 * ## 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