grpc_tls_certificate_provider.cc
Go to the documentation of this file.
1 //
2 // Copyright 2020 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
18 
20 
21 #include <stdint.h>
22 #include <time.h>
23 
24 #include <algorithm>
25 #include <utility>
26 #include <vector>
27 
28 #include <openssl/bio.h>
29 #include <openssl/crypto.h>
30 #include <openssl/evp.h>
31 #include <openssl/pem.h>
32 #include <openssl/x509.h>
33 
34 #include "absl/status/status.h"
35 
37 #include <grpc/slice.h>
38 #include <grpc/support/log.h>
39 #include <grpc/support/time.h>
40 
49 
50 namespace grpc_core {
51 
55  root_certificate_(std::move(root_certificate)),
56  pem_key_cert_pairs_(std::move(pem_key_cert_pairs)) {
58  bool root_being_watched,
59  bool identity_being_watched) {
60  MutexLock lock(&mu_);
62  absl::optional<PemKeyCertPairList> pem_key_cert_pairs;
64  if (!info.root_being_watched && root_being_watched &&
65  !root_certificate_.empty()) {
67  }
68  info.root_being_watched = root_being_watched;
69  if (!info.identity_being_watched && identity_being_watched &&
70  !pem_key_cert_pairs_.empty()) {
71  pem_key_cert_pairs = pem_key_cert_pairs_;
72  }
73  info.identity_being_watched = identity_being_watched;
74  if (!info.root_being_watched && !info.identity_being_watched) {
75  watcher_info_.erase(cert_name);
76  }
77  const bool root_has_update = root_certificate.has_value();
78  const bool identity_has_update = pem_key_cert_pairs.has_value();
79  if (root_has_update || identity_has_update) {
81  std::move(pem_key_cert_pairs));
82  }
83  grpc_error_handle root_cert_error = GRPC_ERROR_NONE;
84  grpc_error_handle identity_cert_error = GRPC_ERROR_NONE;
85  if (root_being_watched && !root_has_update) {
86  root_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
87  "Unable to get latest root certificates.");
88  }
89  if (identity_being_watched && !identity_has_update) {
90  identity_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
91  "Unable to get latest identity certificates.");
92  }
93  if (!GRPC_ERROR_IS_NONE(root_cert_error) ||
94  !GRPC_ERROR_IS_NONE(identity_cert_error)) {
95  distributor_->SetErrorForCert(cert_name, root_cert_error,
96  identity_cert_error);
97  }
98  });
99 }
100 
102  // Reset distributor's callback to make sure the callback won't be invoked
103  // again after this object(provider) is destroyed.
105 }
106 
108  static UniqueTypeName::Factory kFactory("StaticData");
109  return kFactory.Create();
110 }
111 
112 namespace {
113 
114 gpr_timespec TimeoutSecondsToDeadline(int64_t seconds) {
117 }
118 
119 } // namespace
120 
122  std::string private_key_path, std::string identity_certificate_path,
123  std::string root_cert_path, unsigned int refresh_interval_sec)
124  : private_key_path_(std::move(private_key_path)),
125  identity_certificate_path_(std::move(identity_certificate_path)),
126  root_cert_path_(std::move(root_cert_path)),
127  refresh_interval_sec_(refresh_interval_sec),
129  // Private key and identity cert files must be both set or both unset.
131  // Must be watching either root or identity certs.
132  GPR_ASSERT(!private_key_path_.empty() || !root_cert_path_.empty());
134  ForceUpdate();
135  auto thread_lambda = [](void* arg) {
137  static_cast<FileWatcherCertificateProvider*>(arg);
138  GPR_ASSERT(provider != nullptr);
139  while (true) {
140  void* value = gpr_event_wait(
141  &provider->shutdown_event_,
142  TimeoutSecondsToDeadline(provider->refresh_interval_sec_));
143  if (value != nullptr) {
144  return;
145  };
146  provider->ForceUpdate();
147  }
148  };
149  refresh_thread_ = Thread("FileWatcherCertificateProvider_refreshing_thread",
150  thread_lambda, this);
153  bool root_being_watched,
154  bool identity_being_watched) {
155  MutexLock lock(&mu_);
157  absl::optional<PemKeyCertPairList> pem_key_cert_pairs;
159  watcher_info_[cert_name];
160  if (!info.root_being_watched && root_being_watched &&
161  !root_certificate_.empty()) {
162  root_certificate = root_certificate_;
163  }
164  info.root_being_watched = root_being_watched;
165  if (!info.identity_being_watched && identity_being_watched &&
166  !pem_key_cert_pairs_.empty()) {
167  pem_key_cert_pairs = pem_key_cert_pairs_;
168  }
169  info.identity_being_watched = identity_being_watched;
170  if (!info.root_being_watched && !info.identity_being_watched) {
171  watcher_info_.erase(cert_name);
172  }
174  if (root_certificate.has_value() || pem_key_cert_pairs.has_value()) {
176  pem_key_cert_pairs);
177  }
178  grpc_error_handle root_cert_error = GRPC_ERROR_NONE;
179  grpc_error_handle identity_cert_error = GRPC_ERROR_NONE;
180  if (root_being_watched && !root_certificate.has_value()) {
181  root_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
182  "Unable to get latest root certificates.");
183  }
184  if (identity_being_watched && !pem_key_cert_pairs.has_value()) {
185  identity_cert_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
186  "Unable to get latest identity certificates.");
187  }
188  if (!GRPC_ERROR_IS_NONE(root_cert_error) ||
189  !GRPC_ERROR_IS_NONE(identity_cert_error)) {
190  distributor_->SetErrorForCert(cert_name, root_cert_error,
191  identity_cert_error);
192  }
193  });
194 }
195 
197  // Reset distributor's callback to make sure the callback won't be invoked
198  // again after this object(provider) is destroyed.
200  gpr_event_set(&shutdown_event_, reinterpret_cast<void*>(1));
202 }
203 
205  static UniqueTypeName::Factory kFactory("FileWatcher");
206  return kFactory.Create();
207 }
208 
211  absl::optional<PemKeyCertPairList> pem_key_cert_pairs;
212  if (!root_cert_path_.empty()) {
214  }
215  if (!private_key_path_.empty()) {
216  pem_key_cert_pairs = ReadIdentityKeyCertPairFromFiles(
218  }
219  MutexLock lock(&mu_);
220  const bool root_cert_changed =
221  (!root_certificate.has_value() && !root_certificate_.empty()) ||
222  (root_certificate.has_value() && root_certificate_ != *root_certificate);
223  if (root_cert_changed) {
224  if (root_certificate.has_value()) {
225  root_certificate_ = std::move(*root_certificate);
226  } else {
227  root_certificate_ = "";
228  }
229  }
230  const bool identity_cert_changed =
231  (!pem_key_cert_pairs.has_value() && !pem_key_cert_pairs_.empty()) ||
232  (pem_key_cert_pairs.has_value() &&
233  pem_key_cert_pairs_ != *pem_key_cert_pairs);
234  if (identity_cert_changed) {
235  if (pem_key_cert_pairs.has_value()) {
236  pem_key_cert_pairs_ = std::move(*pem_key_cert_pairs);
237  } else {
238  pem_key_cert_pairs_ = {};
239  }
240  }
241  if (root_cert_changed || identity_cert_changed) {
244  "Unable to get latest root certificates.");
245  grpc_error_handle identity_cert_error =
247  "Unable to get latest identity certificates.");
248  for (const auto& p : watcher_info_) {
249  const std::string& cert_name = p.first;
250  const WatcherInfo& info = p.second;
251  absl::optional<std::string> root_to_report;
252  absl::optional<PemKeyCertPairList> identity_to_report;
253  // Set key materials to the distributor if their contents changed.
254  if (info.root_being_watched && !root_certificate_.empty() &&
255  root_cert_changed) {
256  root_to_report = root_certificate_;
257  }
258  if (info.identity_being_watched && !pem_key_cert_pairs_.empty() &&
259  identity_cert_changed) {
260  identity_to_report = pem_key_cert_pairs_;
261  }
262  if (root_to_report.has_value() || identity_to_report.has_value()) {
263  distributor_->SetKeyMaterials(cert_name, std::move(root_to_report),
264  std::move(identity_to_report));
265  }
266  // Report errors to the distributor if the contents are empty.
267  const bool report_root_error =
268  info.root_being_watched && root_certificate_.empty();
269  const bool report_identity_error =
270  info.identity_being_watched && pem_key_cert_pairs_.empty();
271  if (report_root_error || report_identity_error) {
273  cert_name,
274  report_root_error ? GRPC_ERROR_REF(root_cert_error)
275  : GRPC_ERROR_NONE,
276  report_identity_error ? GRPC_ERROR_REF(identity_cert_error)
277  : GRPC_ERROR_NONE);
278  }
279  }
280  GRPC_ERROR_UNREF(root_cert_error);
281  GRPC_ERROR_UNREF(identity_cert_error);
282  }
283 }
284 
287  const std::string& root_cert_full_path) {
288  // Read the root file.
289  grpc_slice root_slice = grpc_empty_slice();
290  grpc_error_handle root_error =
291  grpc_load_file(root_cert_full_path.c_str(), 0, &root_slice);
292  if (!GRPC_ERROR_IS_NONE(root_error)) {
293  gpr_log(GPR_ERROR, "Reading file %s failed: %s",
294  root_cert_full_path.c_str(),
295  grpc_error_std_string(root_error).c_str());
296  GRPC_ERROR_UNREF(root_error);
297  return absl::nullopt;
298  }
299  std::string root_cert(StringViewFromSlice(root_slice));
300  grpc_slice_unref_internal(root_slice);
301  return root_cert;
302 }
303 
304 namespace {
305 
306 // This helper function gets the last-modified time of |filename|. When failed,
307 // it logs the error and returns 0.
308 time_t GetModificationTime(const char* filename) {
309  time_t ts = 0;
311  return ts;
312 }
313 
314 } // namespace
315 
318  const std::string& private_key_path,
319  const std::string& identity_certificate_path) {
320  struct SliceWrapper {
322  ~SliceWrapper() { grpc_slice_unref_internal(slice); }
323  };
324  const int kNumRetryAttempts = 3;
325  for (int i = 0; i < kNumRetryAttempts; ++i) {
326  // TODO(ZhenLian): replace the timestamp approach with key-match approach
327  // once the latter is implemented.
328  // Checking the last modification of identity files before reading.
329  time_t identity_key_ts_before =
330  GetModificationTime(private_key_path.c_str());
331  if (identity_key_ts_before == 0) {
332  gpr_log(
333  GPR_ERROR,
334  "Failed to get the file's modification time of %s. Start retrying...",
335  private_key_path.c_str());
336  continue;
337  }
338  time_t identity_cert_ts_before =
339  GetModificationTime(identity_certificate_path.c_str());
340  if (identity_cert_ts_before == 0) {
341  gpr_log(
342  GPR_ERROR,
343  "Failed to get the file's modification time of %s. Start retrying...",
344  identity_certificate_path.c_str());
345  continue;
346  }
347  // Read the identity files.
348  SliceWrapper key_slice, cert_slice;
349  grpc_error_handle key_error =
350  grpc_load_file(private_key_path.c_str(), 0, &key_slice.slice);
351  if (!GRPC_ERROR_IS_NONE(key_error)) {
352  gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...",
353  private_key_path.c_str(),
354  grpc_error_std_string(key_error).c_str());
355  GRPC_ERROR_UNREF(key_error);
356  continue;
357  }
358  grpc_error_handle cert_error =
359  grpc_load_file(identity_certificate_path.c_str(), 0, &cert_slice.slice);
360  if (!GRPC_ERROR_IS_NONE(cert_error)) {
361  gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...",
362  identity_certificate_path.c_str(),
363  grpc_error_std_string(cert_error).c_str());
364  GRPC_ERROR_UNREF(cert_error);
365  continue;
366  }
367  std::string private_key(StringViewFromSlice(key_slice.slice));
368  std::string cert_chain(StringViewFromSlice(cert_slice.slice));
369  PemKeyCertPairList identity_pairs;
370  identity_pairs.emplace_back(private_key, cert_chain);
371  // Checking the last modification of identity files before reading.
372  time_t identity_key_ts_after =
373  GetModificationTime(private_key_path.c_str());
374  if (identity_key_ts_before != identity_key_ts_after) {
376  "Last modified time before and after reading %s is not the same. "
377  "Start retrying...",
378  private_key_path.c_str());
379  continue;
380  }
381  time_t identity_cert_ts_after =
382  GetModificationTime(identity_certificate_path.c_str());
383  if (identity_cert_ts_before != identity_cert_ts_after) {
385  "Last modified time before and after reading %s is not the same. "
386  "Start retrying...",
387  identity_certificate_path.c_str());
388  continue;
389  }
390  return identity_pairs;
391  }
393  "All retry attempts failed. Will try again after the next interval.");
394  return absl::nullopt;
395 }
396 
399  if (private_key.empty()) {
400  return absl::InvalidArgumentError("Private key string is empty.");
401  }
402  if (cert_chain.empty()) {
403  return absl::InvalidArgumentError("Certificate string is empty.");
404  }
405  BIO* cert_bio = BIO_new_mem_buf(cert_chain.data(), cert_chain.size());
406  if (cert_bio == nullptr) {
408  "Conversion from certificate string to BIO failed.");
409  }
410  // Reads the first cert from the cert_chain which is expected to be the leaf
411  // cert
412  X509* x509 = PEM_read_bio_X509(cert_bio, nullptr, nullptr, nullptr);
413  BIO_free(cert_bio);
414  if (x509 == nullptr) {
416  "Conversion from PEM string to X509 failed.");
417  }
418  EVP_PKEY* public_evp_pkey = X509_get_pubkey(x509);
419  X509_free(x509);
420  if (public_evp_pkey == nullptr) {
422  "Extraction of public key from x.509 certificate failed.");
423  }
424  BIO* private_key_bio =
425  BIO_new_mem_buf(private_key.data(), private_key.size());
426  if (private_key_bio == nullptr) {
427  EVP_PKEY_free(public_evp_pkey);
429  "Conversion from private key string to BIO failed.");
430  }
431  EVP_PKEY* private_evp_pkey =
432  PEM_read_bio_PrivateKey(private_key_bio, nullptr, nullptr, nullptr);
433  BIO_free(private_key_bio);
434  if (private_evp_pkey == nullptr) {
435  EVP_PKEY_free(public_evp_pkey);
437  "Conversion from PEM string to EVP_PKEY failed.");
438  }
439  bool result = EVP_PKEY_cmp(private_evp_pkey, public_evp_pkey) == 1;
440  EVP_PKEY_free(private_evp_pkey);
441  EVP_PKEY_free(public_evp_pkey);
442  return result;
443 }
444 
445 } // namespace grpc_core
446 
450  const char* root_certificate, grpc_tls_identity_pairs* pem_key_cert_pairs) {
451  GPR_ASSERT(root_certificate != nullptr || pem_key_cert_pairs != nullptr);
453  grpc_core::PemKeyCertPairList identity_pairs_core;
454  if (pem_key_cert_pairs != nullptr) {
455  identity_pairs_core = std::move(pem_key_cert_pairs->pem_key_cert_pairs);
456  delete pem_key_cert_pairs;
457  }
458  std::string root_cert_core;
459  if (root_certificate != nullptr) {
460  root_cert_core = root_certificate;
461  }
463  std::move(root_cert_core), std::move(identity_pairs_core));
464 }
465 
468  const char* private_key_path, const char* identity_certificate_path,
469  const char* root_cert_path, unsigned int refresh_interval_sec) {
472  private_key_path == nullptr ? "" : private_key_path,
473  identity_certificate_path == nullptr ? "" : identity_certificate_path,
474  root_cert_path == nullptr ? "" : root_cert_path, refresh_interval_sec);
475 }
476 
478  grpc_tls_certificate_provider* provider) {
479  GRPC_API_TRACE("grpc_tls_certificate_provider_release(provider=%p)", 1,
480  (provider));
482  if (provider != nullptr) provider->Unref();
483 }
trace.h
absl::InvalidArgumentError
Status InvalidArgumentError(absl::string_view message)
Definition: third_party/abseil-cpp/absl/status/status.cc:351
GPR_TIMESPAN
@ GPR_TIMESPAN
Definition: gpr_types.h:45
absl::time_internal::cctz::seconds
std::chrono::duration< std::int_fast64_t > seconds
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h:40
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
grpc_core::UniqueTypeName::Factory::Create
UniqueTypeName Create()
Definition: unique_type_name.h:67
grpc_tls_certificate_provider_release
void grpc_tls_certificate_provider_release(grpc_tls_certificate_provider *provider)
Definition: grpc_tls_certificate_provider.cc:477
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
grpc_core::StaticDataCertificateProvider::mu_
Mutex mu_
Definition: grpc_tls_certificate_provider.h:123
grpc_core::FileWatcherCertificateProvider::private_key_path_
std::string private_key_path_
Definition: grpc_tls_certificate_provider.h:170
grpc_core::MakeRefCounted
RefCountedPtr< T > MakeRefCounted(Args &&... args)
Definition: ref_counted_ptr.h:335
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
log.h
grpc_load_file
grpc_error_handle grpc_load_file(const char *filename, int add_null_terminator, grpc_slice *output)
Definition: load_file.cc:33
grpc_core::StaticDataCertificateProvider::type
UniqueTypeName type() const override
Definition: grpc_tls_certificate_provider.cc:107
load_file.h
bio_st
Definition: bio.h:822
grpc_core::FileWatcherCertificateProvider::mu_
Mutex mu_
Definition: grpc_tls_certificate_provider.h:180
evp.h
slice.h
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::MutexLock
Definition: src/core/lib/gprpp/sync.h:88
bio.h
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_tls_identity_pairs
Definition: grpc_tls_certificate_distributor.h:38
grpc_core::StringViewFromSlice
absl::string_view StringViewFromSlice(const grpc_slice &slice)
Definition: slice_internal.h:93
gpr_event_set
GPRAPI void gpr_event_set(gpr_event *ev, void *value)
Definition: sync.cc:59
grpc_tls_identity_pairs::pem_key_cert_pairs
grpc_core::PemKeyCertPairList pem_key_cert_pairs
Definition: grpc_tls_certificate_distributor.h:39
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_core::FileWatcherCertificateProvider::ReadRootCertificatesFromFile
absl::optional< std::string > ReadRootCertificatesFromFile(const std::string &root_cert_full_path)
Definition: grpc_tls_certificate_provider.cc:286
grpc_core::StaticDataCertificateProvider::~StaticDataCertificateProvider
~StaticDataCertificateProvider() override
Definition: grpc_tls_certificate_provider.cc:101
grpc_tls_certificate_provider_file_watcher_create
grpc_tls_certificate_provider * grpc_tls_certificate_provider_file_watcher_create(const char *private_key_path, const char *identity_certificate_path, const char *root_cert_path, unsigned int refresh_interval_sec)
Definition: grpc_tls_certificate_provider.cc:467
grpc_tls_certificate_distributor
Definition: grpc_tls_certificate_distributor.h:43
status
absl::Status status
Definition: rls.cc:251
grpc_core::FileWatcherCertificateProvider::WatcherInfo
Definition: grpc_tls_certificate_provider.h:147
pem.h
time.h
grpc_core::StaticDataCertificateProvider::distributor_
RefCountedPtr< grpc_tls_certificate_distributor > distributor_
Definition: grpc_tls_certificate_provider.h:119
PEM_read_bio_PrivateKey
EVP_PKEY * PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
Definition: pem_pkey.c:71
X509_free
#define X509_free
Definition: boringssl_prefix_symbols.h:2632
grpc_tls_certificate_distributor::SetKeyMaterials
void SetKeyMaterials(const std::string &cert_name, absl::optional< std::string > pem_root_certs, absl::optional< grpc_core::PemKeyCertPairList > pem_key_cert_pairs)
Definition: grpc_tls_certificate_distributor.cc:27
grpc_core::FileWatcherCertificateProvider::distributor_
RefCountedPtr< grpc_tls_certificate_distributor > distributor_
Definition: grpc_tls_certificate_provider.h:175
X509_get_pubkey
#define X509_get_pubkey
Definition: boringssl_prefix_symbols.h:2669
grpc_core::RefCounted::Unref
void Unref()
Definition: ref_counted.h:302
BIO_new_mem_buf
#define BIO_new_mem_buf
Definition: boringssl_prefix_symbols.h:820
grpc_core::GetFileModificationTime
absl::Status GetFileModificationTime(const char *filename, time_t *timestamp)
grpc_tls_certificate_provider.h
PEM_read_bio_X509
#define PEM_read_bio_X509
Definition: boringssl_prefix_symbols.h:1955
grpc_core::StaticDataCertificateProvider::WatcherInfo
Definition: grpc_tls_certificate_provider.h:108
grpc_core::FileWatcherCertificateProvider::ForceUpdate
void ForceUpdate()
Definition: grpc_tls_certificate_provider.cc:209
evp_pkey_st
Definition: evp.h:1046
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
absl::string_view::size
constexpr size_type size() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:277
absl::optional::has_value
constexpr bool has_value() const noexcept
Definition: abseil-cpp/absl/types/optional.h:461
grpc_core::FileWatcherCertificateProvider::WatcherInfo::root_being_watched
bool root_being_watched
Definition: grpc_tls_certificate_provider.h:148
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
EVP_PKEY_free
#define EVP_PKEY_free
Definition: boringssl_prefix_symbols.h:1625
absl::optional< std::string >
crypto.h
grpc_empty_slice
GPRAPI grpc_slice grpc_empty_slice(void)
Definition: slice/slice.cc:42
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
GPR_CLOCK_MONOTONIC
@ GPR_CLOCK_MONOTONIC
Definition: gpr_types.h:36
grpc_core::FileWatcherCertificateProvider::type
UniqueTypeName type() const override
Definition: grpc_tls_certificate_provider.cc:204
grpc_core::Thread::Join
void Join()
Definition: thd.h:141
gpr_event_init
GPRAPI void gpr_event_init(gpr_event *ev)
Definition: sync.cc:54
grpc_tls_certificate_distributor::SetErrorForCert
void SetErrorForCert(const std::string &cert_name, absl::optional< grpc_error_handle > root_cert_error, absl::optional< grpc_error_handle > identity_cert_error)
Definition: grpc_tls_certificate_distributor.cc:102
error.h
grpc_core::FileWatcherCertificateProvider::shutdown_event_
gpr_event shutdown_event_
Definition: grpc_tls_certificate_provider.h:177
grpc_core::FileWatcherCertificateProvider::refresh_thread_
Thread refresh_thread_
Definition: grpc_tls_certificate_provider.h:176
slice_internal.h
EVP_PKEY_cmp
#define EVP_PKEY_cmp
Definition: boringssl_prefix_symbols.h:1615
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
grpc_core::StaticDataCertificateProvider::WatcherInfo::identity_being_watched
bool identity_being_watched
Definition: grpc_tls_certificate_provider.h:110
grpc_core::FileWatcherCertificateProvider::refresh_interval_sec_
unsigned int refresh_interval_sec_
Definition: grpc_tls_certificate_provider.h:173
distributor_
grpc_core::RefCountedPtr< grpc_tls_certificate_distributor > distributor_
Definition: xds_end2end_test.cc:216
grpc_core::FileWatcherCertificateProvider::identity_certificate_path_
std::string identity_certificate_path_
Definition: grpc_tls_certificate_provider.h:171
grpc_core::FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles
absl::optional< PemKeyCertPairList > ReadIdentityKeyCertPairFromFiles(const std::string &private_key_path, const std::string &identity_certificate_path)
Definition: grpc_tls_certificate_provider.cc:317
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
grpc_core::ExecCtx
Definition: exec_ctx.h:97
grpc_core::Thread::Start
void Start()
Definition: thd.h:125
stdint.h
gpr_event_wait
GPRAPI void * gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline)
Definition: sync.cc:73
grpc_core::FileWatcherCertificateProvider::WatcherInfo::identity_being_watched
bool identity_being_watched
Definition: grpc_tls_certificate_provider.h:149
grpc_core::PrivateKeyAndCertificateMatch
absl::StatusOr< bool > PrivateKeyAndCertificateMatch(absl::string_view private_key, absl::string_view cert_chain)
Definition: grpc_tls_certificate_provider.cc:397
GRPC_ERROR_CREATE_FROM_STATIC_STRING
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc)
Definition: error.h:291
grpc_core::StaticDataCertificateProvider::pem_key_cert_pairs_
PemKeyCertPairList pem_key_cert_pairs_
Definition: grpc_tls_certificate_provider.h:121
gpr_types.h
grpc_core::FileWatcherCertificateProvider::~FileWatcherCertificateProvider
~FileWatcherCertificateProvider() override
Definition: grpc_tls_certificate_provider.cc:196
grpc_tls_certificate_provider_static_data_create
grpc_tls_certificate_provider * grpc_tls_certificate_provider_static_data_create(const char *root_certificate, grpc_tls_identity_pairs *pem_key_cert_pairs)
Definition: grpc_tls_certificate_provider.cc:449
stat.h
value
const char * value
Definition: hpack_parser_table.cc:165
BIO_free
#define BIO_free
Definition: boringssl_prefix_symbols.h:787
GRPC_ERROR_REF
#define GRPC_ERROR_REF(err)
Definition: error.h:261
grpc_core::UniqueTypeName
Definition: unique_type_name.h:56
x509_st
Definition: third_party/boringssl-with-bazel/src/crypto/x509/internal.h:139
gpr_time_add
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
Definition: src/core/lib/gpr/time.cc:135
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
grpc_error_std_string
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:944
grpc_core::StaticDataCertificateProvider::root_certificate_
std::string root_certificate_
Definition: grpc_tls_certificate_provider.h:120
grpc_core::PemKeyCertPairList
std::vector< PemKeyCertPair > PemKeyCertPairList
Definition: ssl_utils.h:183
absl::Status
Definition: third_party/abseil-cpp/absl/status/status.h:424
grpc_core::StaticDataCertificateProvider::StaticDataCertificateProvider
StaticDataCertificateProvider(std::string root_certificate, PemKeyCertPairList pem_key_cert_pairs)
Definition: grpc_tls_certificate_provider.cc:52
private_key
Definition: hrss.c:1885
grpc_core::FileWatcherCertificateProvider::FileWatcherCertificateProvider
FileWatcherCertificateProvider(std::string private_key_path, std::string identity_certificate_path, std::string root_cert_path, unsigned int refresh_interval_sec)
Definition: grpc_tls_certificate_provider.cc:121
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
arg
struct arg arg
exec_ctx.h
slice_refcount.h
grpc_core::Thread
Definition: thd.h:43
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
grpc_core::StaticDataCertificateProvider
Definition: grpc_tls_certificate_provider.h:93
grpc_core::FileWatcherCertificateProvider::root_cert_path_
std::string root_cert_path_
Definition: grpc_tls_certificate_provider.h:172
api_trace.h
grpc_core::StaticDataCertificateProvider::watcher_info_
std::map< std::string, WatcherInfo > watcher_info_
Definition: grpc_tls_certificate_provider.h:126
absl::string_view::empty
constexpr bool empty() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:292
grpc_tls_certificate_provider
Definition: grpc_tls_certificate_provider.h:53
grpc_core::FileWatcherCertificateProvider
Definition: grpc_tls_certificate_provider.h:130
absl::StatusOr
Definition: abseil-cpp/absl/status/statusor.h:187
gpr_timespec
Definition: gpr_types.h:50
grpc_error
Definition: error_internal.h:42
grpc_core::StaticDataCertificateProvider::WatcherInfo::root_being_watched
bool root_being_watched
Definition: grpc_tls_certificate_provider.h:109
tests.interop.resources.private_key
def private_key()
Definition: interop/resources.py:29
absl::string_view::data
constexpr const_pointer data() const noexcept
Definition: abseil-cpp/absl/strings/string_view.h:336
grpc_core::UniqueTypeName::Factory
Definition: unique_type_name.h:60
root_certificate
std::string root_certificate
Definition: xds_end2end_test.cc:142
grpc_tls_certificate_distributor::SetWatchStatusCallback
void SetWatchStatusCallback(std::function< void(std::string, bool, bool)> callback)
Definition: grpc_tls_certificate_distributor.h:133
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
GRPC_API_TRACE
#define GRPC_API_TRACE(fmt, nargs, args)
Definition: api_trace.h:48
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:39
gpr_time_from_seconds
GPRAPI gpr_timespec gpr_time_from_seconds(int64_t s, gpr_clock_type clock_type)
Definition: src/core/lib/gpr/time.cc:123
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition: error.h:241
x509.h
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:45