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

How to verify certificates (not self signed) using PHP

我收到了两个文件,我应该使用 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-----

请注意,域名尚未上线,但我需要了解如何使用这两个文件获取域名。

我找到的解决方案是在 PHP 中使用它:

$contents = file_get_contents($certificate_file_path);

$parsed = openssl_x509_parse($contents);

print_r($parsed);

这将以数组格式为您提供所有相关信息。