| 120 | } |
| 121 | |
| 122 | std::string |
| 123 | SSLSecret::getSecret(const std::string &name) const |
| 124 | { |
| 125 | std::scoped_lock lock(secret_map_mutex); |
| 126 | auto iter = secret_map.find(name); |
| 127 | if (secret_map.end() == iter) { |
| 128 | Dbg(dbg_ctl_ssl_secret, "Get secret for %s: not found", name.c_str()); |
| 129 | return std::string{}; |
| 130 | } |
| 131 | if (iter->second.empty()) { |
| 132 | Dbg(dbg_ctl_ssl_secret, "Get secret for %s: empty", name.c_str()); |
| 133 | return std::string{}; |
| 134 | } |
| 135 | // The full secret data can be sensitive. Print only the first 50 bytes. |
| 136 | if (dbg_ctl_ssl_secret.on()) { |
| 137 | char hash_str[EVP_MAX_MD_SIZE * 2]; |
| 138 | unsigned int hash_len; |
| 139 | get_hash_str(iter->second, hash_str, &hash_len); |
| 140 | DbgPrint(dbg_ctl_ssl_secret, "Get secret for %s: hash=%.*s %.50s", name.c_str(), hash_len, hash_str, iter->second.c_str()); |
| 141 | } |
| 142 | return iter->second; |
| 143 | } |
| 144 | |
| 145 | void |
| 146 | SSLSecret::getOrLoadSecret(const std::string &name1, const std::string &name2, std::string &data1, std::string &data2) |