Search code examples
phppkix509

openssl_x509_parse returning false



I'm pulling a user certificate and attempting to use their information to log them in. This is what I have so far. Running on Apache with PHP I'm able to echo the $_SERVER variable which is an array that holds a variety of information about the user including what I'm assuming to be the client certificate.

I'm even able to run the following command:

echo($_SERVER['HTTP_SSL_CLIENT_CERT']);

the line above outputs the whole:

-----BEGIN CERTIFICATE---- BLAH...BLAH...BLAH -----END CERTIFICATE-----

However if I run the following command:

$cert_data = openssl_x509_parse($_SERVER['HTTP_SSL_CLIENT_CERT']);

It returns false and I can't seem to get anything out of it.

I've tried: openssl_x509_read as well to no avail.

I'm wondering if I need a new line after the:
-----BEGIN CERTIFICATE----- because it seems as though the certificate is just one big long line of text.

Thanks in advance!


Solution

  • After revisiting the problem it turns out that I needed to add the following line to the Apache httpd.conf file

    SSLOptions +StdEnvVars +ExportCertData
    

    Hope that helps someone.