32 auto& cert_info = certificate_info_map_[cert_name];
36 for (
auto* watcher_ptr : cert_info.root_cert_watchers) {
38 const auto watcher_it =
watchers_.find(watcher_ptr);
40 GPR_ASSERT(watcher_it->second.root_cert_name.has_value());
42 pem_key_cert_pairs_to_report;
44 watcher_it->second.identity_cert_name == cert_name) {
45 pem_key_cert_pairs_to_report = pem_key_cert_pairs;
46 }
else if (watcher_it->second.identity_cert_name.has_value()) {
47 auto& identity_cert_info =
48 certificate_info_map_[*watcher_it->second.identity_cert_name];
49 if (!identity_cert_info.pem_key_cert_pairs.empty()) {
50 pem_key_cert_pairs_to_report = identity_cert_info.pem_key_cert_pairs;
53 watcher_ptr->OnCertificatesChanged(
61 for (
const auto watcher_ptr : cert_info.identity_cert_watchers) {
63 const auto watcher_it =
watchers_.find(watcher_ptr);
65 GPR_ASSERT(watcher_it->second.identity_cert_name.has_value());
68 watcher_it->second.root_cert_name == cert_name) {
72 }
else if (watcher_it->second.root_cert_name.has_value()) {
73 auto& root_cert_info =
74 certificate_info_map_[*watcher_it->second.root_cert_name];
75 if (!root_cert_info.pem_root_certs.empty()) {
76 pem_root_certs_to_report = root_cert_info.pem_root_certs;
79 watcher_ptr->OnCertificatesChanged(pem_root_certs_to_report,
82 cert_info.pem_key_cert_pairs =
std::move(*pem_key_cert_pairs);
89 const auto it = certificate_info_map_.find(root_cert_name);
90 return it != certificate_info_map_.end() &&
91 !
it->second.pem_root_certs.empty();
97 const auto it = certificate_info_map_.find(identity_cert_name);
98 return it != certificate_info_map_.end() &&
99 !
it->second.pem_key_cert_pairs.empty();
112 const auto watcher_it =
watchers_.find(watcher_ptr);
118 watcher_it->second.identity_cert_name == cert_name) {
119 identity_cert_error_to_report = *identity_cert_error;
120 }
else if (watcher_it->second.identity_cert_name.has_value()) {
121 auto& identity_cert_info =
122 certificate_info_map_[*watcher_it->second.identity_cert_name];
123 identity_cert_error_to_report = identity_cert_info.identity_cert_error;
133 const auto watcher_it =
watchers_.find(watcher_ptr);
139 watcher_it->second.root_cert_name == cert_name) {
143 }
else if (watcher_it->second.root_cert_name.has_value()) {
144 auto& root_cert_info =
145 certificate_info_map_[*watcher_it->second.root_cert_name];
146 root_cert_error_to_report = root_cert_info.root_cert_error;
159 const auto watcher_ptr =
watcher.first;
161 const auto& watcher_info =
watcher.second;
162 watcher_ptr->OnError(
168 for (
auto& cert_info_entry : certificate_info_map_) {
169 auto& cert_info = cert_info_entry.second;
177 std::unique_ptr<TlsCertificatesWatcherInterface>
watcher,
180 bool start_watching_root_cert =
false;
181 bool already_watching_identity_for_root_cert =
false;
182 bool start_watching_identity_cert =
false;
183 bool already_watching_root_for_identity_cert =
false;
190 const auto watcher_it =
watchers_.find(watcher_ptr);
203 already_watching_identity_for_root_cert =
213 CertificateInfo& cert_info = certificate_info_map_[*identity_cert_name];
215 already_watching_root_for_identity_cert =
245 if (watch_status_callback_ !=
nullptr) {
246 if (root_cert_name == identity_cert_name &&
247 (start_watching_root_cert || start_watching_identity_cert)) {
248 watch_status_callback_(*root_cert_name, start_watching_root_cert,
249 start_watching_identity_cert);
251 if (start_watching_root_cert) {
252 watch_status_callback_(*root_cert_name,
true,
253 already_watching_identity_for_root_cert);
255 if (start_watching_identity_cert) {
256 watch_status_callback_(*identity_cert_name,
257 already_watching_root_for_identity_cert,
true);
268 bool stop_watching_root_cert =
false;
269 bool already_watching_identity_for_root_cert =
false;
270 bool stop_watching_identity_cert =
false;
271 bool already_watching_root_for_identity_cert =
false;
282 auto it = certificate_info_map_.find(*root_cert_name);
287 already_watching_identity_for_root_cert =
289 if (stop_watching_root_cert && !already_watching_identity_for_root_cert) {
290 certificate_info_map_.erase(
it);
294 auto it = certificate_info_map_.find(*identity_cert_name);
299 already_watching_root_for_identity_cert =
301 if (stop_watching_identity_cert &&
302 !already_watching_root_for_identity_cert) {
303 certificate_info_map_.erase(
it);
310 if (watch_status_callback_ !=
nullptr) {
311 if (root_cert_name == identity_cert_name &&
312 (stop_watching_root_cert || stop_watching_identity_cert)) {
313 watch_status_callback_(*root_cert_name, !stop_watching_root_cert,
314 !stop_watching_identity_cert);
316 if (stop_watching_root_cert) {
317 watch_status_callback_(*root_cert_name,
false,
318 already_watching_identity_for_root_cert);
320 if (stop_watching_identity_cert) {
321 watch_status_callback_(*identity_cert_name,
322 already_watching_root_for_identity_cert,
338 const char* cert_chain) {