grpc 1.59.2 → 1.59.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,7 @@
33
33
  #include <sys/socket.h>
34
34
  #endif
35
35
 
36
+ #include <memory>
36
37
  #include <string>
37
38
 
38
39
  #include <openssl/bio.h>
@@ -48,6 +49,7 @@
48
49
  #include "absl/strings/str_cat.h"
49
50
  #include "absl/strings/string_view.h"
50
51
 
52
+ #include <grpc/grpc_crl_provider.h>
51
53
  #include <grpc/grpc_security.h>
52
54
  #include <grpc/support/alloc.h>
53
55
  #include <grpc/support/log.h>
@@ -57,6 +59,7 @@
57
59
 
58
60
  #include "src/core/lib/gpr/useful.h"
59
61
  #include "src/core/lib/gprpp/crash.h"
62
+ #include "src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h"
60
63
  #include "src/core/tsi/ssl/key_logging/ssl_key_logging.h"
61
64
  #include "src/core/tsi/ssl/session_cache/ssl_session_cache.h"
62
65
  #include "src/core/tsi/ssl_transport_security_utils.h"
@@ -144,6 +147,7 @@ struct tsi_ssl_frame_protector {
144
147
 
145
148
  static gpr_once g_init_openssl_once = GPR_ONCE_INIT;
146
149
  static int g_ssl_ctx_ex_factory_index = -1;
150
+ static int g_ssl_ctx_ex_crl_provider_index = -1;
147
151
  static const unsigned char kSslSessionIdContext[] = {'g', 'r', 'p', 'c'};
148
152
  static int g_ssl_ex_verified_root_cert_index = -1;
149
153
  #if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_NO_ENGINE)
@@ -199,6 +203,10 @@ static void init_openssl(void) {
199
203
  SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
200
204
  GPR_ASSERT(g_ssl_ctx_ex_factory_index != -1);
201
205
 
206
+ g_ssl_ctx_ex_crl_provider_index =
207
+ SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
208
+ GPR_ASSERT(g_ssl_ctx_ex_crl_provider_index != -1);
209
+
202
210
  g_ssl_ex_verified_root_cert_index =
203
211
  SSL_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
204
212
  GPR_ASSERT(g_ssl_ex_verified_root_cert_index != -1);
@@ -876,9 +884,9 @@ static tsi_result build_alpn_protocol_name_list(
876
884
  static int verify_cb(int ok, X509_STORE_CTX* ctx) {
877
885
  int cert_error = X509_STORE_CTX_get_error(ctx);
878
886
  if (cert_error == X509_V_ERR_UNABLE_TO_GET_CRL) {
879
- gpr_log(
880
- GPR_INFO,
881
- "Certificate verification failed to get CRL files. Ignoring error.");
887
+ gpr_log(GPR_INFO,
888
+ "Certificate verification failed to find relevant CRL file. "
889
+ "Ignoring error.");
882
890
  return 1;
883
891
  }
884
892
  if (cert_error != 0) {
@@ -940,8 +948,16 @@ static int RootCertExtractCallback(int preverify_ok, X509_STORE_CTX* ctx) {
940
948
  return preverify_ok;
941
949
  }
942
950
 
943
- SSL* ssl = static_cast<SSL*>(
944
- X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
951
+ ERR_clear_error();
952
+ int ssl_index = SSL_get_ex_data_X509_STORE_CTX_idx();
953
+ if (ssl_index < 0) {
954
+ char err_str[256];
955
+ ERR_error_string_n(ERR_get_error(), err_str, sizeof(err_str));
956
+ gpr_log(GPR_ERROR,
957
+ "error getting the SSL index from the X509_STORE_CTX: %s", err_str);
958
+ return preverify_ok;
959
+ }
960
+ SSL* ssl = static_cast<SSL*>(X509_STORE_CTX_get_ex_data(ctx, ssl_index));
945
961
  if (ssl == nullptr) {
946
962
  return preverify_ok;
947
963
  }
@@ -953,6 +969,69 @@ static int RootCertExtractCallback(int preverify_ok, X509_STORE_CTX* ctx) {
953
969
  return preverify_ok;
954
970
  }
955
971
 
972
+ // X509_STORE_set_get_crl() sets the function to get the crl for a given
973
+ // certificate x. When found, the crl must be assigned to *crl. This function
974
+ // must return 0 on failure and 1 on success. If no function to get the issuer
975
+ // is provided, the internal default function will be used instead.
976
+ static int GetCrlFromProvider(X509_STORE_CTX* ctx, X509_CRL** crl_out,
977
+ X509* cert) {
978
+ ERR_clear_error();
979
+ int ssl_index = SSL_get_ex_data_X509_STORE_CTX_idx();
980
+ if (ssl_index < 0) {
981
+ char err_str[256];
982
+ ERR_error_string_n(ERR_get_error(), err_str, sizeof(err_str));
983
+ gpr_log(GPR_ERROR,
984
+ "error getting the SSL index from the X509_STORE_CTX while looking "
985
+ "up Crl: %s",
986
+ err_str);
987
+ return 0;
988
+ }
989
+ SSL* ssl = static_cast<SSL*>(X509_STORE_CTX_get_ex_data(ctx, ssl_index));
990
+ if (ssl == nullptr) {
991
+ gpr_log(GPR_ERROR,
992
+ "error while fetching from CrlProvider. SSL object is null");
993
+ return 0;
994
+ }
995
+ SSL_CTX* ssl_ctx = SSL_get_SSL_CTX(ssl);
996
+ auto* provider = static_cast<grpc_core::experimental::CrlProvider*>(
997
+ SSL_CTX_get_ex_data(ssl_ctx, g_ssl_ctx_ex_crl_provider_index));
998
+
999
+ char* buf = X509_NAME_oneline(X509_get_issuer_name(cert), nullptr, 0);
1000
+ if (buf == nullptr) {
1001
+ gpr_log(GPR_ERROR, "Certificate has null issuer, cannot do CRL lookup");
1002
+ return 0;
1003
+ }
1004
+ grpc_core::experimental::CertificateInfoImpl cert_impl(buf);
1005
+ std::shared_ptr<grpc_core::experimental::Crl> internal_crl =
1006
+ provider->GetCrl(cert_impl);
1007
+ OPENSSL_free(buf);
1008
+ // There wasn't a CRL found in the provider. Returning 0 will end up causing
1009
+ // OpenSSL to return X509_V_ERR_UNABLE_TO_GET_CRL. We then catch that error
1010
+ // and behave how we want for a missing CRL.
1011
+ // It is important to treat missing CRLs and empty CRLs differently.
1012
+ if (internal_crl == nullptr) {
1013
+ return 0;
1014
+ }
1015
+ X509_CRL* crl =
1016
+ std::static_pointer_cast<grpc_core::experimental::CrlImpl>(internal_crl)
1017
+ ->crl();
1018
+
1019
+ X509_CRL* copy = X509_CRL_dup(crl);
1020
+ *crl_out = copy;
1021
+ return 1;
1022
+ }
1023
+
1024
+ // When using CRL Providers, this function used to override the default
1025
+ // `check_crl` function in OpenSSL using `X509_STORE_set_check_crl`.
1026
+ // CrlProviders put the onus on the users to provide the CRLs that they want to
1027
+ // provide, and because we override default CRL fetching behavior, we can expect
1028
+ // some of these verification checks to fails for custom CRL providers as well.
1029
+ // Thus, we need a passthrough to indicate to OpenSSL that we've provided a CRL
1030
+ // and we are good with it.
1031
+ static int CheckCrlPassthrough(X509_STORE_CTX* /*ctx*/, X509_CRL* /*crl*/) {
1032
+ return 1;
1033
+ }
1034
+
956
1035
  // Sets the min and max TLS version of |ssl_context| to |min_tls_version| and
957
1036
  // |max_tls_version|, respectively. Calling this method is a no-op when using
958
1037
  // OpenSSL versions < 1.1.
@@ -2088,10 +2167,18 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options(
2088
2167
  }
2089
2168
 
2090
2169
  #if OPENSSL_VERSION_NUMBER >= 0x10100000
2091
- if (options->crl_directory != nullptr &&
2092
- strcmp(options->crl_directory, "") != 0) {
2093
- gpr_log(GPR_INFO, "enabling client CRL checking with path: %s",
2094
- options->crl_directory);
2170
+ if (options->crl_provider != nullptr) {
2171
+ SSL_CTX_set_ex_data(impl->ssl_context, g_ssl_ctx_ex_crl_provider_index,
2172
+ options->crl_provider.get());
2173
+ X509_STORE* cert_store = SSL_CTX_get_cert_store(impl->ssl_context);
2174
+ X509_STORE_set_get_crl(cert_store, GetCrlFromProvider);
2175
+ X509_STORE_set_check_crl(cert_store, CheckCrlPassthrough);
2176
+ X509_STORE_set_verify_cb(cert_store, verify_cb);
2177
+ X509_VERIFY_PARAM* param = X509_STORE_get0_param(cert_store);
2178
+ X509_VERIFY_PARAM_set_flags(
2179
+ param, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
2180
+ } else if (options->crl_directory != nullptr &&
2181
+ strcmp(options->crl_directory, "") != 0) {
2095
2182
  X509_STORE* cert_store = SSL_CTX_get_cert_store(ssl_context);
2096
2183
  X509_STORE_set_verify_cb(cert_store, verify_cb);
2097
2184
  if (!X509_STORE_load_locations(cert_store, nullptr,
@@ -2101,7 +2188,6 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options(
2101
2188
  X509_VERIFY_PARAM* param = X509_STORE_get0_param(cert_store);
2102
2189
  X509_VERIFY_PARAM_set_flags(
2103
2190
  param, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
2104
- gpr_log(GPR_INFO, "enabled client side CRL checking.");
2105
2191
  }
2106
2192
  }
2107
2193
  #endif
@@ -2276,10 +2362,19 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options(
2276
2362
  }
2277
2363
 
2278
2364
  #if OPENSSL_VERSION_NUMBER >= 0x10100000
2279
- if (options->crl_directory != nullptr &&
2280
- strcmp(options->crl_directory, "") != 0) {
2281
- gpr_log(GPR_INFO, "enabling server CRL checking with path %s",
2282
- options->crl_directory);
2365
+ if (options->crl_provider != nullptr) {
2366
+ SSL_CTX_set_ex_data(impl->ssl_contexts[i],
2367
+ g_ssl_ctx_ex_crl_provider_index,
2368
+ options->crl_provider.get());
2369
+ X509_STORE* cert_store = SSL_CTX_get_cert_store(impl->ssl_contexts[i]);
2370
+ X509_STORE_set_get_crl(cert_store, GetCrlFromProvider);
2371
+ X509_STORE_set_check_crl(cert_store, CheckCrlPassthrough);
2372
+ X509_STORE_set_verify_cb(cert_store, verify_cb);
2373
+ X509_VERIFY_PARAM* param = X509_STORE_get0_param(cert_store);
2374
+ X509_VERIFY_PARAM_set_flags(
2375
+ param, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
2376
+ } else if (options->crl_directory != nullptr &&
2377
+ strcmp(options->crl_directory, "") != 0) {
2283
2378
  X509_STORE* cert_store = SSL_CTX_get_cert_store(impl->ssl_contexts[i]);
2284
2379
  X509_STORE_set_verify_cb(cert_store, verify_cb);
2285
2380
  if (!X509_STORE_load_locations(cert_store, nullptr,
@@ -2289,7 +2384,6 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options(
2289
2384
  X509_VERIFY_PARAM* param = X509_STORE_get0_param(cert_store);
2290
2385
  X509_VERIFY_PARAM_set_flags(
2291
2386
  param, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
2292
- gpr_log(GPR_INFO, "enabled server CRL checking.");
2293
2387
  }
2294
2388
  }
2295
2389
  #endif
@@ -21,10 +21,13 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
+ #include <memory>
25
+
24
26
  #include <openssl/x509.h>
25
27
 
26
28
  #include "absl/strings/string_view.h"
27
29
 
30
+ #include <grpc/grpc_crl_provider.h>
28
31
  #include <grpc/grpc_security_constants.h>
29
32
 
30
33
  #include "src/core/tsi/ssl/key_logging/ssl_key_logging.h"
@@ -179,9 +182,17 @@ struct tsi_ssl_client_handshaker_options {
179
182
  // The directory where all hashed CRL files enforced by the handshaker are
180
183
  // located. If the directory is invalid, CRL checking will fail open and just
181
184
  // log. An empty directory will not enable crl checking. Only OpenSSL version
182
- // > 1.1 is supported for CRL checking
185
+ // >= 1.1 is supported for CRL checking. Cannot be used in conjunction with
186
+ // `crl_provider`.
183
187
  const char* crl_directory;
184
188
 
189
+ // A provider of CRLs. If set, when doing handshakes the `CrlProvider`'s
190
+ // `GetCrl` function will be called to find CRLs when checking certificates
191
+ // for revocation. Cannot be used in conjunction with `crl_directory`.
192
+ // This provider is created and owned by the user and passed in through
193
+ // options as a shared_ptr.
194
+ std::shared_ptr<grpc_core::experimental::CrlProvider> crl_provider;
195
+
185
196
  tsi_ssl_client_handshaker_options()
186
197
  : pem_key_cert_pair(nullptr),
187
198
  pem_root_certs(nullptr),
@@ -329,6 +340,13 @@ struct tsi_ssl_server_handshaker_options {
329
340
  // crl checking. Only OpenSSL version > 1.1 is supported for CRL checking
330
341
  const char* crl_directory;
331
342
 
343
+ // A provider of CRLs. If set, when doing handshakes the `CrlProvider`'s
344
+ // `GetCrl` function will be called to find CRLs when checking certificates
345
+ // for revocation. Cannot be used in conjunction with `crl_directory`.
346
+ // This provider is created and owned by the user and passed in through
347
+ // options as a shared_ptr.
348
+ std::shared_ptr<grpc_core::experimental::CrlProvider> crl_provider;
349
+
332
350
  // If true, the SSL server sends a list of CA names to the client in the
333
351
  // ServerHello. This list of CA names is extracted from the server's trust
334
352
  // bundle, and the client may use this lint as a hint to decide which
@@ -180,6 +180,8 @@ grpc_tls_certificate_provider_static_data_create_type grpc_tls_certificate_provi
180
180
  grpc_tls_certificate_provider_file_watcher_create_type grpc_tls_certificate_provider_file_watcher_create_import;
181
181
  grpc_tls_certificate_provider_release_type grpc_tls_certificate_provider_release_import;
182
182
  grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import;
183
+ grpc_tls_credentials_options_set_min_tls_version_type grpc_tls_credentials_options_set_min_tls_version_import;
184
+ grpc_tls_credentials_options_set_max_tls_version_type grpc_tls_credentials_options_set_max_tls_version_import;
183
185
  grpc_tls_credentials_options_set_certificate_provider_type grpc_tls_credentials_options_set_certificate_provider_import;
184
186
  grpc_tls_credentials_options_watch_root_certs_type grpc_tls_credentials_options_watch_root_certs_import;
185
187
  grpc_tls_credentials_options_set_root_cert_name_type grpc_tls_credentials_options_set_root_cert_name_import;
@@ -467,6 +469,8 @@ void grpc_rb_load_imports(HMODULE library) {
467
469
  grpc_tls_certificate_provider_file_watcher_create_import = (grpc_tls_certificate_provider_file_watcher_create_type) GetProcAddress(library, "grpc_tls_certificate_provider_file_watcher_create");
468
470
  grpc_tls_certificate_provider_release_import = (grpc_tls_certificate_provider_release_type) GetProcAddress(library, "grpc_tls_certificate_provider_release");
469
471
  grpc_tls_credentials_options_create_import = (grpc_tls_credentials_options_create_type) GetProcAddress(library, "grpc_tls_credentials_options_create");
472
+ grpc_tls_credentials_options_set_min_tls_version_import = (grpc_tls_credentials_options_set_min_tls_version_type) GetProcAddress(library, "grpc_tls_credentials_options_set_min_tls_version");
473
+ grpc_tls_credentials_options_set_max_tls_version_import = (grpc_tls_credentials_options_set_max_tls_version_type) GetProcAddress(library, "grpc_tls_credentials_options_set_max_tls_version");
470
474
  grpc_tls_credentials_options_set_certificate_provider_import = (grpc_tls_credentials_options_set_certificate_provider_type) GetProcAddress(library, "grpc_tls_credentials_options_set_certificate_provider");
471
475
  grpc_tls_credentials_options_watch_root_certs_import = (grpc_tls_credentials_options_watch_root_certs_type) GetProcAddress(library, "grpc_tls_credentials_options_watch_root_certs");
472
476
  grpc_tls_credentials_options_set_root_cert_name_import = (grpc_tls_credentials_options_set_root_cert_name_type) GetProcAddress(library, "grpc_tls_credentials_options_set_root_cert_name");
@@ -515,6 +515,12 @@ extern grpc_tls_certificate_provider_release_type grpc_tls_certificate_provider_
515
515
  typedef grpc_tls_credentials_options*(*grpc_tls_credentials_options_create_type)(void);
516
516
  extern grpc_tls_credentials_options_create_type grpc_tls_credentials_options_create_import;
517
517
  #define grpc_tls_credentials_options_create grpc_tls_credentials_options_create_import
518
+ typedef void(*grpc_tls_credentials_options_set_min_tls_version_type)(grpc_tls_credentials_options* options, grpc_tls_version min_tls_version);
519
+ extern grpc_tls_credentials_options_set_min_tls_version_type grpc_tls_credentials_options_set_min_tls_version_import;
520
+ #define grpc_tls_credentials_options_set_min_tls_version grpc_tls_credentials_options_set_min_tls_version_import
521
+ typedef void(*grpc_tls_credentials_options_set_max_tls_version_type)(grpc_tls_credentials_options* options, grpc_tls_version max_tls_version);
522
+ extern grpc_tls_credentials_options_set_max_tls_version_type grpc_tls_credentials_options_set_max_tls_version_import;
523
+ #define grpc_tls_credentials_options_set_max_tls_version grpc_tls_credentials_options_set_max_tls_version_import
518
524
  typedef void(*grpc_tls_credentials_options_set_certificate_provider_type)(grpc_tls_credentials_options* options, grpc_tls_certificate_provider* provider);
519
525
  extern grpc_tls_credentials_options_set_certificate_provider_type grpc_tls_credentials_options_set_certificate_provider_import;
520
526
  #define grpc_tls_credentials_options_set_certificate_provider grpc_tls_credentials_options_set_certificate_provider_import
@@ -14,5 +14,5 @@
14
14
 
15
15
  # GRPC contains the General RPC module.
16
16
  module GRPC
17
- VERSION = '1.59.2'
17
+ VERSION = '1.59.5'
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.59.2
4
+ version: 1.59.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - gRPC Authors
8
8
  autorequire:
9
9
  bindir: src/ruby/bin
10
10
  cert_chain: []
11
- date: 2023-10-30 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -219,6 +219,7 @@ files:
219
219
  - include/grpc/fork.h
220
220
  - include/grpc/grpc.h
221
221
  - include/grpc/grpc_audit_logging.h
222
+ - include/grpc/grpc_crl_provider.h
222
223
  - include/grpc/grpc_cronet.h
223
224
  - include/grpc/grpc_posix.h
224
225
  - include/grpc/grpc_security.h
@@ -1382,6 +1383,7 @@ files:
1382
1383
  - src/core/lib/gprpp/crash.cc
1383
1384
  - src/core/lib/gprpp/crash.h
1384
1385
  - src/core/lib/gprpp/debug_location.h
1386
+ - src/core/lib/gprpp/directory_reader.h
1385
1387
  - src/core/lib/gprpp/dual_ref_counted.h
1386
1388
  - src/core/lib/gprpp/env.h
1387
1389
  - src/core/lib/gprpp/examine_stack.cc
@@ -1406,6 +1408,7 @@ files:
1406
1408
  - src/core/lib/gprpp/packed_table.h
1407
1409
  - src/core/lib/gprpp/per_cpu.cc
1408
1410
  - src/core/lib/gprpp/per_cpu.h
1411
+ - src/core/lib/gprpp/posix/directory_reader.cc
1409
1412
  - src/core/lib/gprpp/posix/env.cc
1410
1413
  - src/core/lib/gprpp/posix/stat.cc
1411
1414
  - src/core/lib/gprpp/posix/thd.cc
@@ -1435,6 +1438,7 @@ files:
1435
1438
  - src/core/lib/gprpp/unique_type_name.h
1436
1439
  - src/core/lib/gprpp/validation_errors.cc
1437
1440
  - src/core/lib/gprpp/validation_errors.h
1441
+ - src/core/lib/gprpp/windows/directory_reader.cc
1438
1442
  - src/core/lib/gprpp/windows/env.cc
1439
1443
  - src/core/lib/gprpp/windows/stat.cc
1440
1444
  - src/core/lib/gprpp/windows/thd.cc
@@ -1749,6 +1753,8 @@ files:
1749
1753
  - src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h
1750
1754
  - src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
1751
1755
  - src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h
1756
+ - src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc
1757
+ - src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h
1752
1758
  - src/core/lib/security/credentials/tls/tls_credentials.cc
1753
1759
  - src/core/lib/security/credentials/tls/tls_credentials.h
1754
1760
  - src/core/lib/security/credentials/tls/tls_utils.cc
@@ -3292,7 +3298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
3292
3298
  - !ruby/object:Gem::Version
3293
3299
  version: '0'
3294
3300
  requirements: []
3295
- rubygems_version: 3.4.21
3301
+ rubygems_version: 3.5.17
3296
3302
  signing_key:
3297
3303
  specification_version: 4
3298
3304
  summary: GRPC system in Ruby