Skip to content

Commit 2d34ccf

Browse files
authored
Softfail when receiving a X509_V_ERR_UNABLE_TO_GET_CRL error (grpc#29124)
1 parent 4d40184 commit 2d34ccf

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

src/core/tsi/ssl_transport_security.cc

+8
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,16 @@ static void ssl_keylogging_callback(const SSL* ssl, const char* info) {
19391939
factory->key_logger->LogSessionKeys(ssl_context, info);
19401940
}
19411941

1942+
// This callback is invoked when the CRL has been verified and will soft-fail
1943+
// errors in verification depending on certain error types.
19421944
static int verify_cb(int ok, X509_STORE_CTX* ctx) {
19431945
int cert_error = X509_STORE_CTX_get_error(ctx);
1946+
if (cert_error == X509_V_ERR_UNABLE_TO_GET_CRL) {
1947+
gpr_log(
1948+
GPR_INFO,
1949+
"Certificate verification failed to get CRL files. Ignoring error.");
1950+
return 1;
1951+
}
19441952
if (cert_error != 0) {
19451953
gpr_log(GPR_ERROR, "Certificate verify failed with code %d", cert_error);
19461954
}

test/core/tsi/crl_ssl_transport_security_test.cc

+30-8
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,22 @@ const int kSslTsiTestRevokedKeyCertPairsNum = 1;
4343
const int kSslTsiTestValidKeyCertPairsNum = 1;
4444
const char* kSslTsiTestCrlSupportedCredentialsDir =
4545
"test/core/tsi/test_creds/crl_data/";
46+
const char* kSslTsiTestFaultyCrlsDir = "bad_path/";
4647

4748
class CrlSslTransportSecurityTest
4849
: public testing::TestWithParam<tsi_tls_version> {
4950
protected:
5051
// A tsi_test_fixture implementation.
5152
class SslTsiTestFixture {
5253
public:
54+
// When use_faulty_crl_directory is set, the crl_directory of the
55+
// client is set to a non-existant path.
5356
static SslTsiTestFixture* Create(bool use_revoked_server_cert,
54-
bool use_revoked_client_cert) {
57+
bool use_revoked_client_cert,
58+
bool use_faulty_crl_directory) {
5559
return new SslTsiTestFixture(use_revoked_server_cert,
56-
use_revoked_client_cert);
60+
use_revoked_client_cert,
61+
use_faulty_crl_directory);
5762
}
5863

5964
void Run() {
@@ -63,9 +68,11 @@ class CrlSslTransportSecurityTest
6368

6469
private:
6570
SslTsiTestFixture(bool use_revoked_server_cert,
66-
bool use_revoked_client_cert)
71+
bool use_revoked_client_cert,
72+
bool use_faulty_crl_directory)
6773
: use_revoked_server_cert_(use_revoked_server_cert),
68-
use_revoked_client_cert_(use_revoked_client_cert) {
74+
use_revoked_client_cert_(use_revoked_client_cert),
75+
use_faulty_crl_directory_(use_faulty_crl_directory) {
6976
tsi_test_fixture_init(&base_);
7077
base_.test_unused_bytes = true;
7178
base_.vtable = &kVtable;
@@ -120,7 +127,11 @@ class CrlSslTransportSecurityTest
120127
} else {
121128
client_options.pem_key_cert_pair = valid_pem_key_cert_pairs_;
122129
}
123-
client_options.crl_directory = kSslTsiTestCrlSupportedCredentialsDir;
130+
if (use_faulty_crl_directory_) {
131+
client_options.crl_directory = kSslTsiTestFaultyCrlsDir;
132+
} else {
133+
client_options.crl_directory = kSslTsiTestCrlSupportedCredentialsDir;
134+
}
124135
client_options.root_store = root_store_;
125136
client_options.min_tls_version = GetParam();
126137
client_options.max_tls_version = GetParam();
@@ -228,6 +239,7 @@ class CrlSslTransportSecurityTest
228239
tsi_test_fixture base_;
229240
bool use_revoked_server_cert_;
230241
bool use_revoked_client_cert_;
242+
bool use_faulty_crl_directory_;
231243
char* root_cert_;
232244
tsi_ssl_root_certs_store* root_store_;
233245
tsi_ssl_pem_key_cert_pair* revoked_pem_key_cert_pairs_;
@@ -245,19 +257,29 @@ struct tsi_test_fixture_vtable
245257

246258
TEST_P(CrlSslTransportSecurityTest, RevokedServerCert) {
247259
auto* fixture = SslTsiTestFixture::Create(/*use_revoked_server_cert=*/true,
248-
/*use_revoked_client_cert=*/false);
260+
/*use_revoked_client_cert=*/false,
261+
/*use_faulty_crl_directory=*/false);
249262
fixture->Run();
250263
}
251264

252265
TEST_P(CrlSslTransportSecurityTest, RevokedClientCert) {
253266
auto* fixture = SslTsiTestFixture::Create(/*use_revoked_server_cert=*/false,
254-
/*use_revoked_client_cert=*/true);
267+
/*use_revoked_client_cert=*/true,
268+
/*use_faulty_crl_directory=*/false);
255269
fixture->Run();
256270
}
257271

258272
TEST_P(CrlSslTransportSecurityTest, ValidCerts) {
259273
auto* fixture = SslTsiTestFixture::Create(/*use_revoked_server_cert=*/false,
260-
/*use_revoked_client_cert=*/false);
274+
/*use_revoked_client_cert=*/false,
275+
/*use_faulty_crl_directory=*/false);
276+
fixture->Run();
277+
}
278+
279+
TEST_P(CrlSslTransportSecurityTest, UseFaultyCrlDirectory) {
280+
auto* fixture = SslTsiTestFixture::Create(/*use_revoked_server_cert=*/false,
281+
/*use_revoked_client_cert=*/false,
282+
/*use_faulty_crl_directory=*/true);
261283
fixture->Run();
262284
}
263285

0 commit comments

Comments
 (0)