Skip to content

Commit 7881888

Browse files
committed
CDRIVER-3580 soft-fail with schannel
With schannel, if certificate validation occurs due to: - certificates not having revocation info - OCSP responder / CRL distribution being offline Consider this a soft-failure.
1 parent 90a7ac4 commit 7881888

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/libmongoc/doc/configuring_tls.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ When ``tlsCAFile`` is set, the driver will only allow server certificates issued
123123

124124
When ``crl_file`` is set with :symbol:`mongoc_ssl_opt_t`, the driver will import the revocation list to the ``System Local Machine Root`` certificate store.
125125

126-
Setting ``tlsDisableOCSPEndpointCheck`` has no effect.
127-
128-
Setting ``tlsAllowInvalidHostnames`` additionally consider certificates with no revocation mechanisms specified (CRL / OCSP) a non-error.
126+
Setting ``tlsDisableOCSPEndpointCheck`` and ``tlsDisableCertificateRevocationCheck`` has no effect.
129127

130128
The Online Certificate Status Protocol (OCSP) is partially supported (see `RFC 6960 <https://tools.ietf.org/html/rfc6960>`_).
131129

src/libmongoc/src/mongoc/mongoc-secure-channel.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,7 @@ mongoc_secure_channel_handshake_step_2 (mongoc_stream_tls_t *tls,
820820
break;
821821
case CRYPT_E_NO_REVOCATION_CHECK:
822822
MONGOC_ERROR ("SSL Certification verification failed: certificate "
823-
"does not include revocation check. Set "
824-
"tlsDisableCertificateRevocationCheck to disable "
825-
"revocation checking");
823+
"does not include revocation check.");
826824
break;
827825

828826
case SEC_E_INSUFFICIENT_MEMORY:

src/libmongoc/src/mongoc/mongoc-stream-tls-secure-channel.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -974,24 +974,23 @@ mongoc_stream_tls_secure_channel_new (mongoc_stream_t *base_stream,
974974
schannel_cred.dwFlags = SCH_USE_STRONG_CRYPTO;
975975
#endif
976976

977+
/* By default, enable soft failing.
978+
* A certificate with no revocation check is a soft failure. */
979+
schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK;
980+
/* An offline OCSP responder / CRL distribution list is a soft failure. */
981+
schannel_cred.dwFlags |= SCH_CRED_IGNORE_REVOCATION_OFFLINE;
982+
977983
if (opt->weak_cert_validation) {
978-
schannel_cred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION |
979-
SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
980-
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
984+
schannel_cred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION;
981985
TRACE ("%s", "disabled server certificate checks");
982-
} else if (_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) {
983-
schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
984-
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
985-
TRACE ("%s", "disabled server certificate revocation checks");
986986
} else {
987987
schannel_cred.dwFlags |=
988988
SCH_CRED_AUTO_CRED_VALIDATION | SCH_CRED_REVOCATION_CHECK_CHAIN;
989989
TRACE ("%s", "enabled server certificate checks");
990990
}
991991

992992
if (opt->allow_invalid_hostname) {
993-
schannel_cred.dwFlags |=
994-
SCH_CRED_NO_SERVERNAME_CHECK | SCH_CRED_IGNORE_NO_REVOCATION_CHECK;
993+
schannel_cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK;
995994
}
996995

997996
if (opt->ca_file) {
@@ -1064,6 +1063,11 @@ mongoc_stream_tls_secure_channel_new (mongoc_stream_t *base_stream,
10641063
"built against Secure Channel");
10651064
}
10661065

1066+
if (_mongoc_ssl_opts_disable_certificate_revocation_check (opt)) {
1067+
MONGOC_ERROR ("Setting tlsDisableCertificateRevocationCheck has no "
1068+
"effect when built Secure Channel");
1069+
}
1070+
10671071
mongoc_counter_streams_active_inc ();
10681072
RETURN ((mongoc_stream_t *) tls);
10691073
}

0 commit comments

Comments
 (0)