| 133 | } |
| 134 | |
| 135 | int |
| 136 | CB_Update_Secret(TSCont cont, TSEvent /* event ATS_UNUSED */, void * /* edata ATS_UNUSED */) |
| 137 | { |
| 138 | std::vector<std::string> updates; |
| 139 | for (auto iter = secret_versions.begin(); iter != secret_versions.end(); ++iter) { |
| 140 | std::string newname; |
| 141 | std::string data_item; |
| 142 | struct stat statdata; |
| 143 | |
| 144 | update_file_name(iter->first, newname); |
| 145 | Dbg(dbg_ctl, "check secret for %s, really %s", iter->first.c_str(), newname.c_str()); |
| 146 | |
| 147 | if (stat(newname.c_str(), &statdata) < 0) { |
| 148 | continue; |
| 149 | } |
| 150 | |
| 151 | if (statdata.st_mtime > iter->second) { |
| 152 | Dbg(dbg_ctl, "check secret %s has been updated", newname.c_str()); |
| 153 | if (!load_file(newname, &statdata, data_item)) { |
| 154 | continue; |
| 155 | } |
| 156 | TSSslSecretSet(iter->first.c_str(), iter->first.length(), data_item.data(), data_item.size()); |
| 157 | updates.push_back(iter->first); |
| 158 | iter->second = statdata.st_mtime; |
| 159 | } |
| 160 | } |
| 161 | for (auto name : updates) { |
| 162 | Dbg(dbg_ctl, "update cert for secret %s", name.c_str()); |
| 163 | TSSslSecretUpdate(name.c_str(), name.length()); |
| 164 | } |
| 165 | TSContScheduleOnPool(cont, 3000, TS_THREAD_POOL_TASK); |
| 166 | return TS_SUCCESS; |
| 167 | } |
| 168 | |
| 169 | // Called by ATS as our initialization point |
| 170 | void |
nothing calls this directly
no test coverage detected