Skip to content

Instantly share code, notes, and snippets.

@rikatz
Created October 24, 2017 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rikatz/9e5840fa6034042c57480646ea5db956 to your computer and use it in GitHub Desktop.
Save rikatz/9e5840fa6034042c57480646ea5db956 to your computer and use it in GitHub Desktop.
Test Certificate existense
<?php
$headers = apache_request_headers();
$cert1 = str_replace("\\n","\n",$headers['ssl-client-cert']);
if(!empty($cert1)) {
$certificado = openssl_x509_read($cert1);
$certuser = openssl_x509_parse($certificado);
$username = $certuser['subject']['CN'];
echo "CERTIF USER: $username";
} else {
print_r('User/Password logins not enabled');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment