summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_server.c
diff options
context:
space:
mode:
authortb <>2021-02-03 07:06:14 +0000
committertb <>2021-02-03 07:06:14 +0000
commit70029edfad38276befdaee62f4fe7e084070c0cd (patch)
tree9f524641600313fef6d235a1c7bfeced27fbe075 /src/lib/libssl/tls13_server.c
parent7708b34c3988d3cd2e01b8bd5d4f1a64461e6464 (diff)
downloadopenbsd-70029edfad38276befdaee62f4fe7e084070c0cd.tar.gz
openbsd-70029edfad38276befdaee62f4fe7e084070c0cd.tar.bz2
openbsd-70029edfad38276befdaee62f4fe7e084070c0cd.zip
This is errata/6.8/013_libressl.patch.siglibressl-v3.2.4
Various interoperability issues and memory leaks were discovered in libcrypto and libssl. The new verifier is not bug compatible with the old verifier and caused many issues by failing to propagate errors correctly, returning different error codes than some software was trained to expect and otherwise failing when it shouldn't. While much of this is fixed in -current, it's still not perfect, so switching back to the legacy verifier is preferable at this point. Other included fixes: * Unbreak DTLS retransmissions for flights that include a CCS * Only check BIO_should_read() on read and BIO_should_write() on write * Implement autochain for the TLSv1.3 server * Use the legacy verifier for AUTO_CHAIN * Implement exporter for TLSv1.3 * Free alert_data and phh_data in tls13_record_layer_free() * Plug leak in x509_verify_chain_dup() * Free the policy tree in x509_vfy_check_policy() Original commits by jsing and tb ok inoguchi jsing
Diffstat (limited to '')
-rw-r--r--src/lib/libssl/tls13_server.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/lib/libssl/tls13_server.c b/src/lib/libssl/tls13_server.c
index a5c03b610c..f9b557d2ac 100644
--- a/src/lib/libssl/tls13_server.c
+++ b/src/lib/libssl/tls13_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_server.c,v 1.61 2020/07/03 04:12:51 tb Exp $ */ 1/* $OpenBSD: tls13_server.c,v 1.61.4.1 2021/02/03 07:06:14 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
@@ -611,6 +611,7 @@ tls13_server_certificate_send(struct tls13_ctx *ctx, CBB *cbb)
611 SSL *s = ctx->ssl; 611 SSL *s = ctx->ssl;
612 CBB cert_request_context, cert_list; 612 CBB cert_request_context, cert_list;
613 const struct ssl_sigalg *sigalg; 613 const struct ssl_sigalg *sigalg;
614 X509_STORE_CTX *xsc = NULL;
614 STACK_OF(X509) *chain; 615 STACK_OF(X509) *chain;
615 CERT_PKEY *cpk; 616 CERT_PKEY *cpk;
616 X509 *cert; 617 X509 *cert;
@@ -633,6 +634,18 @@ tls13_server_certificate_send(struct tls13_ctx *ctx, CBB *cbb)
633 if ((chain = cpk->chain) == NULL) 634 if ((chain = cpk->chain) == NULL)
634 chain = s->ctx->extra_certs; 635 chain = s->ctx->extra_certs;
635 636
637 if (chain == NULL && !(s->internal->mode & SSL_MODE_NO_AUTO_CHAIN)) {
638 if ((xsc = X509_STORE_CTX_new()) == NULL)
639 goto err;
640 if (!X509_STORE_CTX_init(xsc, s->ctx->cert_store, cpk->x509, NULL))
641 goto err;
642 X509_VERIFY_PARAM_set_flags(X509_STORE_CTX_get0_param(xsc),
643 X509_V_FLAG_LEGACY_VERIFY);
644 X509_verify_cert(xsc);
645 ERR_clear_error();
646 chain = xsc->chain;
647 }
648
636 if (!CBB_add_u8_length_prefixed(cbb, &cert_request_context)) 649 if (!CBB_add_u8_length_prefixed(cbb, &cert_request_context))
637 goto err; 650 goto err;
638 if (!CBB_add_u24_length_prefixed(cbb, &cert_list)) 651 if (!CBB_add_u24_length_prefixed(cbb, &cert_list))
@@ -643,6 +656,15 @@ tls13_server_certificate_send(struct tls13_ctx *ctx, CBB *cbb)
643 656
644 for (i = 0; i < sk_X509_num(chain); i++) { 657 for (i = 0; i < sk_X509_num(chain); i++) {
645 cert = sk_X509_value(chain, i); 658 cert = sk_X509_value(chain, i);
659
660 /*
661 * In the case of auto chain, the leaf certificate will be at
662 * the top of the chain - skip over it as we've already added
663 * it earlier.
664 */
665 if (i == 0 && cert == cpk->x509)
666 continue;
667
646 /* 668 /*
647 * XXX we don't send extensions with chain certs to avoid sending 669 * XXX we don't send extensions with chain certs to avoid sending
648 * a leaf ocsp stape with the chain certs. This needs to get 670 * a leaf ocsp stape with the chain certs. This needs to get
@@ -658,6 +680,8 @@ tls13_server_certificate_send(struct tls13_ctx *ctx, CBB *cbb)
658 ret = 1; 680 ret = 1;
659 681
660 err: 682 err:
683 X509_STORE_CTX_free(xsc);
684
661 return ret; 685 return ret;
662} 686}
663 687