Move X509-related verification code into ssl_x509.c. Change-Id: I9f94033036550ae85c98cd4e09584972b4441b5d Reviewed-on: https://boringssl-review.googlesource.com/13971 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index cd9d4c4..a37de06 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c
@@ -235,11 +235,6 @@ return NULL; } - if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) { - OPENSSL_PUT_ERROR(SSL, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); - goto err; - } - ret = OPENSSL_malloc(sizeof(SSL_CTX)); if (ret == NULL) { goto err; @@ -271,8 +266,8 @@ if (ret->sessions == NULL) { goto err; } - ret->cert_store = X509_STORE_new(); - if (ret->cert_store == NULL) { + + if (!ret->x509_method->ssl_ctx_new(ret)) { goto err; } @@ -284,11 +279,6 @@ goto err2; } - ret->param = X509_VERIFY_PARAM_new(); - if (!ret->param) { - goto err; - } - ret->client_CA = sk_CRYPTO_BUFFER_new_null(); if (ret->client_CA == NULL) { goto err; @@ -337,8 +327,6 @@ return; } - X509_VERIFY_PARAM_free(ctx->param); - /* Free internal session cache. However: the remove_cb() may reference the * ex_data of SSL_CTX, thus the ex_data store can only be removed after the * sessions were flushed. As the ex_data handling routines might also touch @@ -351,7 +339,6 @@ CRYPTO_MUTEX_cleanup(&ctx->lock); lh_SSL_SESSION_free(ctx->sessions); - X509_STORE_free(ctx->cert_store); ssl_cipher_preference_list_free(ctx->cipher_list); ssl_cert_free(ctx->cert); sk_SSL_CUSTOM_EXTENSION_pop_free(ctx->client_custom_extensions, @@ -359,7 +346,7 @@ sk_SSL_CUSTOM_EXTENSION_pop_free(ctx->server_custom_extensions, SSL_CUSTOM_EXTENSION_free); sk_CRYPTO_BUFFER_pop_free(ctx->client_CA, CRYPTO_BUFFER_free); - ctx->x509_method->ssl_ctx_flush_cached_client_CA(ctx); + ctx->x509_method->ssl_ctx_free(ctx); sk_SRTP_PROTECTION_PROFILE_free(ctx->srtp_profiles); OPENSSL_free(ctx->psk_identity_hint); OPENSSL_free(ctx->supported_group_list); @@ -408,11 +395,6 @@ ssl->retain_only_sha256_of_client_certs = ctx->retain_only_sha256_of_client_certs; - ssl->param = X509_VERIFY_PARAM_new(); - if (!ssl->param) { - goto err; - } - X509_VERIFY_PARAM_inherit(ssl->param, ctx->param); ssl->quiet_shutdown = ctx->quiet_shutdown; ssl->max_send_fragment = ctx->max_send_fragment; @@ -421,6 +403,10 @@ SSL_CTX_up_ref(ctx); ssl->initial_ctx = ctx; + if (!ssl->ctx->x509_method->ssl_new(ssl)) { + goto err; + } + if (ctx->supported_group_list) { ssl->supported_group_list = BUF_memdup(ctx->supported_group_list, ctx->supported_group_list_len * 2); @@ -482,8 +468,7 @@ return; } - X509_VERIFY_PARAM_free(ssl->param); - + ssl->ctx->x509_method->ssl_free(ssl); CRYPTO_free_ex_data(&g_ex_data_class_ssl, ssl, &ssl->ex_data); BIO_free_all(ssl->rbio); @@ -505,7 +490,6 @@ EVP_PKEY_free(ssl->tlsext_channel_id_private); OPENSSL_free(ssl->psk_identity_hint); sk_CRYPTO_BUFFER_pop_free(ssl->client_CA, CRYPTO_BUFFER_free); - ssl->ctx->x509_method->ssl_flush_cached_client_CA(ssl); sk_SRTP_PROTECTION_PROFILE_free(ssl->srtp_profiles); if (ssl->method != NULL) {