mirror of
https://github.com/ipxe/ipxe.git
synced 2026-08-26 13:17:22 -05:00
[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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user