如何使用PHP验证证书(非自签名)

I have received two files and I am supposed to validate using PHP!

One file starts with -----BEGIN CERTIFICATE-----

and ends with -----END CERTIFICATE-----

The second file starts with -----BEGIN RSA PRIVATE KEY-----

and ends with -----END RSA PRIVATE KEY-----

Kindly note that the domains are not online yet but I need to find out how to get the domain names by using these two files.

The solution that I found is to use this in PHP:

$contents = file_get_contents($certificate_file_path);

$parsed = openssl_x509_parse($contents);

print_r($parsed);

This will give you every associated information in an array format.