MCPcopy Create free account
hub / github.com/acl-dev/acl / create_host_key

Method create_host_key

lib_acl_cpp/src/stream/mbedtls_conf.cpp:980–1008  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978}
979
980bool mbedtls_conf::create_host_key(string& host, string& key, size_t skip /* 0 */)
981{
982 key.clear();
983
984 std::vector<string>& tokens = host.split2(".");
985 if (tokens.empty() || tokens.size() <= skip) {
986 return false;
987 }
988
989 // Reverse the host name split with '.'. for example:
990 // www.sina.com --> com.sina.com
991 // *.sina.com --> com.sina.
992 // The last char '*' will be changed to '.' above.
993 // When skip == 1, then "www.sina.com --> com.sina"
994
995 int size = (int) tokens.size();
996 for (int i = size - 1; i >= (int) skip; --i) {
997 const string& token = tokens[i];
998 if (i != size - 1) {
999 key += ".";
1000 }
1001 if (token == "*") {
1002 break;
1003 }
1004 key += token;
1005 }
1006
1007 return true;
1008}
1009
1010MBEDTLS_CERT_KEY* mbedtls_conf::find_ssl_config(const char* host)
1011{

Callers

nothing calls this directly

Calls 3

clearMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected