Browse Source

Allow users of the |CRYPTO_BUFFER|-based methods to verify certs after the handshake.

Previously, the |CRYPTO_BUFFER|-based methods always rejected
certificate chains because none of the current callbacks is suitable to
use. In the medium-term, we want an async callback for this but, for
now, we would like to get Chromium working. Chromium already installs a
no-op callback (except for the logic that was moved into BoringSSL in
a58baaf9e6) and so this hack will suffice
for Chromium.

Change-Id: Ie44b7b32b9e42f503c47b072e958507754136d72
Reviewed-on: https://boringssl-review.googlesource.com/14125
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
kris/onging/CECPQ3_patch15
Adam Langley 7 years ago
committed by CQ bot account: commit-bot@chromium.org
parent
commit
fe36672bf5
3 changed files with 25 additions and 2 deletions
  1. +13
    -0
      include/openssl/ssl.h
  2. +4
    -0
      ssl/ssl_lib.c
  3. +8
    -2
      ssl/tls_method.c

+ 13
- 0
include/openssl/ssl.h View File

@@ -2266,6 +2266,13 @@ OPENSSL_EXPORT void SSL_CTX_set_cert_verify_callback(
SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *store_ctx, void *arg),
void *arg);

/* SSL_CTX_i_promise_to_verify_certs_after_the_handshake indicates that the
* caller understands that the |CRYPTO_BUFFER|-based methods currently require
* post-handshake verification of certificates and thus it's ok to accept any
* certificates during the handshake. */
OPENSSL_EXPORT void SSL_CTX_i_promise_to_verify_certs_after_the_handshake(
SSL_CTX *ctx);

/* SSL_enable_signed_cert_timestamps causes |ssl| (which must be the client end
* of a connection) to request SCTs from the server. See
* https://tools.ietf.org/html/rfc6962.
@@ -4137,6 +4144,12 @@ struct ssl_ctx_st {
/* grease_enabled is one if draft-davidben-tls-grease-01 is enabled and zero
* otherwise. */
unsigned grease_enabled:1;

/* i_promise_to_verify_certs_after_the_handshake indicates that the
* application is using the |CRYPTO_BUFFER|-based methods and understands
* that this currently requires post-handshake verification of
* certificates. */
unsigned i_promise_to_verify_certs_after_the_handshake:1;
};




+ 4
- 0
ssl/ssl_lib.c View File

@@ -1598,6 +1598,10 @@ void SSL_CTX_enable_signed_cert_timestamps(SSL_CTX *ctx) {
ctx->signed_cert_timestamps_enabled = 1;
}

void SSL_CTX_i_promise_to_verify_certs_after_the_handshake(SSL_CTX *ctx) {
ctx->i_promise_to_verify_certs_after_the_handshake = 1;
}

void SSL_enable_signed_cert_timestamps(SSL *ssl) {
ssl->signed_cert_timestamps_enabled = 1;
}


+ 8
- 2
ssl/tls_method.c View File

@@ -278,8 +278,14 @@ static int ssl_noop_x509_session_dup(SSL_SESSION *new_session,
static void ssl_noop_x509_session_clear(SSL_SESSION *session) {}
static int ssl_noop_x509_session_verify_cert_chain(SSL_SESSION *session,
SSL *ssl) {
OPENSSL_PUT_ERROR(SSL, SSL_R_CERTIFICATE_VERIFY_FAILED);
return 0;
if (!ssl->ctx->i_promise_to_verify_certs_after_the_handshake) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNKNOWN_CA);
OPENSSL_PUT_ERROR(SSL, SSL_R_CERTIFICATE_VERIFY_FAILED);
return 0;
}

session->verify_result = X509_V_OK;
return 1;
}

static void ssl_noop_x509_hs_flush_cached_ca_names(SSL_HANDSHAKE *hs) {}


Loading…
Cancel
Save