Hello again, and thanks to both of you for taking the time to reply. I have tried both alternatives though I also have problems with both.
Starting from Derokorian's suggestion, here's what I did:
$result = shell_exec("echo -n | openssl s_client -connect localhost:80 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > Documents/php/test.cert");
echo $result;
This doesn't do anything, however. It's a problem I previously had because I tried something very similar (here) but the main issue is that it seems my configuration (I'm running LAMP on Ubuntu 12.04) lacks the necessary permissions to execute shell commands from PHP. If I do shell_exec("whoami") it works (and returns www-data), if I try just about any other command it doesn't work. I checked my php.ini file and my Safe Mode (which is usually responsible for exec and its variants not working) is off. I don't know what else there could be that prevents me from using most executable commands on the command line from PHP. Any ideas?
Now for NogDog's suggestion, here's what I did:
[CODE// general page info
curl_setopt($myurl, CURLOPT_VERBOSE, 1); // required for CURLOPT_CERTINFO
curl_setopt($myurl, CURLOPT_CERTINFO, 1); // extracts certification info from the website at $myurl
curl_setopt($ch, CURLOPT_URL,"https://www.digicert.com/");
curl_setopt($myurl, CURLOPT_HEADER, 1); // includes header in report
curl_setopt($myurl, CURLOPT_NOBODY, 1); // excludes body from report
curl_setopt($myurl, CURLOPT_STDERR, $fileshort); // redirects output to file
curl_setopt($myurl, CURLOPT_SSL_VERIFYPEER, true); // required for CURLOPT_CAPATH
curl_setopt($myurl, CURLOPT_SSL_VERIFYHOST, 2); // verifies host certificate + that it matches hostname provided
curl_setopt($myurl, CURLOPT_SSLVERSION, 3); // sets SSL version to 3
curl_setopt($myurl, CURLOPT_CAINFO, "/etc/ssl/certs/cacert.pem"); // check certificate against list of certified authorities
// execute
$findlinks = curl_exec($myurl);
echo curl_getinfo($myurl, CURLINFO_HTTP_CODE);[/CODE]
Where $fileshort is the destination path of the file I want to write to.
However, it does not write to said file (path is /Documents/php/getres.txt and I tried without the first slash too, but it still doesn't work). The other problem is that the information I get here does not contain the EV certificate information, which I need.
I hope I have sufficiently explained my problems. Any other ideas?