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

Function tlsCheckAgainstAllowlist

src/tls.cpp:522–531  ·  view source on GitHub ↗

Check to see if a given client name is contained in the provided set (allowlist/blocklist) * Return true if it does */

Source from the content-addressed store, hash-verified

520/* Check to see if a given client name is contained in the provided set (allowlist/blocklist)
521 * Return true if it does */
522bool tlsCheckAgainstAllowlist(const char * client, std::set<sdsstring> set){
523 /* Because of wildcard matching, we need to iterate over the entire set.
524 * If we were doing simply straight matching, we could just directly
525 * check to see if the client name is in the set in O(1) time */
526 for (auto &client_pattern: set){
527 if (stringmatchlen(client_pattern.get(), client_pattern.size(), client, strlen(client), 1))
528 return true;
529 }
530 return false;
531}
532
533/* Sets the sha256 certificate fingerprint on the connection
534 * Based on the example here https://fm4dd.com/openssl/certfprint.shtm */

Callers 1

Calls 3

stringmatchlenFunction · 0.85
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected