[crypto] Use certificate's own public key algorithm for key matching When finding the certificate corresponding to a private key, the match is currently performed using the certificate's signature algorithm (i.e. the public key algorithm of the issuer's key) rather than the certificate's own public key algorithm. This breaks key matching for heterogenous certificate chains (e.g. an ECDSA client certificate issued by an RSA intermediate certificate). Fix by using the certificate's own public key algorithm. Signed-off-by: Michael Brown <mcb30@ipxe.org>
diff --git a/src/crypto/x509.c b/src/crypto/x509.c index 111c747..a35fc3a 100644 --- a/src/crypto/x509.c +++ b/src/crypto/x509.c
@@ -1866,7 +1866,7 @@ /* Check public key */ cert = link->cert; - if ( pubkey_match ( cert->signature_algorithm->pubkey, + if ( pubkey_match ( cert->subject.public_key.algorithm->pubkey, privkey_cursor ( key ), &cert->subject.public_key.raw ) == 0 ) return x509_found ( store, cert );