[tls] Make certificate processing visibly safe at point of use

Following the example of commit 8ef91dd ("[tls] Make certificate
sending visibly safe at point of use"), add runtime checks in the
functions that consume the server certificate chain so that the safety
guarantee becomes immediately visible, and to avoid potential future
bugs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-08-25 23:16:41 +01:00
parent 8ef91ddc8d
commit 0167b5a39f
+8
View File
@@ -1149,6 +1149,10 @@ static int tls_key_encrypt ( struct tls_connection *tls,
int rc;
/* Identify server certificate */
if ( ! tls->server.chain ) {
DBGC ( tls, "TLS %p has no server certificate chain\n", tls );
return -ENOENT_CERT;
}
cert = x509_first ( tls->server.chain );
if ( ! cert ) {
DBGC ( tls, "TLS %p has no server certificate\n", tls );
@@ -2653,6 +2657,10 @@ static int tls_new_server_key_exchange ( struct tls_connection *tls,
int rc;
/* Identify server certificate */
if ( ! tls->server.chain ) {
DBGC ( tls, "TLS %p has no server certificate chain\n", tls );
return -ENOENT_CERT;
}
cert = x509_first ( tls->server.chain );
if ( ! cert ) {
DBGC ( tls, "TLS %p has no server certificate\n", tls );