Skip to content

Commit

Permalink
Improve handling when no certificate is provided.
Browse files Browse the repository at this point in the history
- PHP 7.4 (sensibly) raises a notice when trying to access `false`
  as if it where an array, i.e. via
  $Plain_Client_Cerfificate['name']
  • Loading branch information
gregcorbett committed Jan 24, 2025
1 parent 5474afb commit 4a58855
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Authentication/AuthTokens/X509AuthenticationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ private function getDN() {
$Raw_Client_Certificate = $_SERVER['SSL_CLIENT_CERT'];
if (isset($Raw_Client_Certificate)) {
$Plain_Client_Cerfificate = openssl_x509_parse($Raw_Client_Certificate);

// $Plain_Client_Cerfificate will be an array in the presence of
// a certificate, otherwise, it will be `false`.
if (is_array($Plain_Client_Cerfificate)) {
// Then no valid certificate was provided.
return;
}

$User_DN = $Plain_Client_Cerfificate['name'];
if (isset($User_DN)) {
// Check that the dn does not contain a backslash - utf8 chars
Expand Down

0 comments on commit 4a58855

Please sign in to comment.