| 143 | } |
| 144 | |
| 145 | void |
| 146 | SSLSecret::getOrLoadSecret(const std::string &name1, const std::string &name2, std::string &data1, std::string &data2) |
| 147 | { |
| 148 | Dbg(dbg_ctl_ssl_secret, "lookup up secrets for %s and %s", name1.c_str(), name2.c_str()); |
| 149 | { |
| 150 | std::scoped_lock lock(secret_map_mutex); |
| 151 | std::string *const data1ptr = &(secret_map[name1]); |
| 152 | std::string *const data2ptr = [&]() -> std::string * { |
| 153 | if (name2.empty()) { |
| 154 | data2.clear(); |
| 155 | return &data2; |
| 156 | } |
| 157 | return &(secret_map[name2]); |
| 158 | }(); |
| 159 | data1 = *data1ptr; |
| 160 | data2 = *data2ptr; |
| 161 | } |
| 162 | // If we can't find either secret, load them both again |
| 163 | if (data1.empty() || (!name2.empty() && data2.empty())) { |
| 164 | std::string data1tmp; |
| 165 | std::string data2tmp; |
| 166 | this->loadSecret(name1, name2, data1tmp, data2tmp); |
| 167 | data1 = std::move(data1tmp); |
| 168 | data2 = std::move(data2tmp); |
| 169 | } |
| 170 | } |
no test coverage detected