How do I match a certificate file to a key file?

Compare the modulus of the files.

Check the public key like this:

openssl x509 -in /path/to/cert.crt -noout -text

And check the private keys like this:

openssl rsa -in /path/to/cert.key -noout -text

Compare the "modulus" data (a big block of numbers) between the certificate and the potentially matching keys. If they match, then the key and certificate are a pair.