Passed
Push — release_2_0 ( e3bdbe...41ee3b )
by Stefan
06:33
created
core/SilverbulletCertificate.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function annotate($annotation) {
145 145
         $encoded = json_encode($annotation);
146 146
         $this->annotation = $encoded;
147
-        $this->databaseHandle->exec("UPDATE silverbullet_certificate SET extrainfo = ? WHERE serial_number = ?", "si", $encoded, $this->serial );
147
+        $this->databaseHandle->exec("UPDATE silverbullet_certificate SET extrainfo = ? WHERE serial_number = ?", "si", $encoded, $this->serial);
148 148
     }
149 149
     /**
150 150
      * we don't use caching in SB, so this function does nothing
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $invitationObject = new SilverbulletInvitation($token);
171 171
         $profile = new ProfileSilverbullet($invitationObject->profile);
172 172
         $inst = new IdP($profile->institution);
173
-        $loggerInstance->debug(5, "tokenStatus: done, got " . $invitationObject->invitationTokenStatus . ", " . $invitationObject->profile . ", " . $invitationObject->userId . ", " . $invitationObject->expiry . ", " . $invitationObject->invitationTokenString . "\n");
173
+        $loggerInstance->debug(5, "tokenStatus: done, got ".$invitationObject->invitationTokenStatus.", ".$invitationObject->profile.", ".$invitationObject->userId.", ".$invitationObject->expiry.", ".$invitationObject->invitationTokenString."\n");
174 174
         if ($invitationObject->invitationTokenStatus != SilverbulletInvitation::SB_TOKENSTATUS_VALID && $invitationObject->invitationTokenStatus != SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) {
175 175
             throw new Exception("Attempt to generate a SilverBullet installer with an invalid/redeemed/expired token. The user should never have gotten that far!");
176 176
         }
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
             throw new Exception("Despite a valid token, the corresponding user was not found in database or database query error!");
184 184
         }
185 185
         $expiryObject = mysqli_fetch_object(/** @scrutinizer ignore-type */ $userrow);
186
-        $loggerInstance->debug(5, "EXP: " . $expiryObject->expiry . "\n");
186
+        $loggerInstance->debug(5, "EXP: ".$expiryObject->expiry."\n");
187 187
         $expiryDateObject = date_create_from_format("Y-m-d H:i:s", $expiryObject->expiry);
188 188
         if ($expiryDateObject === FALSE) {
189 189
             throw new Exception("The expiry date we got from the DB is bogus!");
190 190
         }
191
-        $loggerInstance->debug(5, $expiryDateObject->format("Y-m-d H:i:s") . "\n");
191
+        $loggerInstance->debug(5, $expiryDateObject->format("Y-m-d H:i:s")."\n");
192 192
         // date_create with no parameters can't fail, i.e. is never FALSE
193 193
         $validity = date_diff(/** @scrutinizer ignore-type */ date_create(), $expiryDateObject);
194 194
         $expiryDays = $validity->days + 1;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $certString = "";
238 238
         openssl_x509_export($cert, $certString);
239 239
         $parsedCert = $x509->processCertificate($certString);
240
-        $loggerInstance->debug(5, "CERTINFO: " . print_r($parsedCert['full_details'], true));
240
+        $loggerInstance->debug(5, "CERTINFO: ".print_r($parsedCert['full_details'], true));
241 241
         $realExpiryDate = date_create_from_format("U", $parsedCert['full_details']['validTo_time_t'])->format("Y-m-d H:i:s");
242 242
 
243 243
         // store new cert info in DB
@@ -295,26 +295,26 @@  discard block
 block discarded – undo
295 295
                 $cat = new CAT();
296 296
                 $tempdirArray = $cat->createTemporaryDirectory("test");
297 297
                 $tempdir = $tempdirArray['dir'];
298
-                $nowIndexTxt = (new \DateTime())->format("ymdHis") . "Z";
299
-                $expiryIndexTxt = $originalExpiry->format("ymdHis") . "Z";
298
+                $nowIndexTxt = (new \DateTime())->format("ymdHis")."Z";
299
+                $expiryIndexTxt = $originalExpiry->format("ymdHis")."Z";
300 300
                 $serialHex = strtoupper(dechex($this->serial));
301 301
                 if (strlen($serialHex) % 2 == 1) {
302
-                    $serialHex = "0" . $serialHex;
302
+                    $serialHex = "0".$serialHex;
303 303
                 }
304 304
 
305
-                $indexStatement = "$certstatus\t$expiryIndexTxt\t" . ($certstatus == "R" ? "$nowIndexTxt,unspecified" : "") . "\t$serialHex\tunknown\t/O=" . CONFIG_CONFASSISTANT['CONSORTIUM']['name'] . "/OU=$federation/CN=$this->username\n";
305
+                $indexStatement = "$certstatus\t$expiryIndexTxt\t".($certstatus == "R" ? "$nowIndexTxt,unspecified" : "")."\t$serialHex\tunknown\t/O=".CONFIG_CONFASSISTANT['CONSORTIUM']['name']."/OU=$federation/CN=$this->username\n";
306 306
                 $logHandle->debug(4, "index.txt contents-to-be: $indexStatement");
307
-                if (!file_put_contents($tempdir . "/index.txt", $indexStatement)) {
307
+                if (!file_put_contents($tempdir."/index.txt", $indexStatement)) {
308 308
                     $logHandle->debug(1, "Unable to write openssl index.txt file for revocation handling!");
309 309
                 }
310 310
                 // index.txt.attr is dull but needs to exist
311
-                file_put_contents($tempdir . "/index.txt.attr", "unique_subject = yes\n");
311
+                file_put_contents($tempdir."/index.txt.attr", "unique_subject = yes\n");
312 312
                 // call "openssl ocsp" to manufacture our own OCSP statement
313 313
                 // adding "-rmd sha1" to the following command-line makes the
314 314
                 // choice of signature algorithm for the response explicit
315 315
                 // but it's only available from openssl-1.1.0 (which we do not
316 316
                 // want to require just for that one thing).
317
-                $execCmd = CONFIG['PATHS']['openssl'] . " ocsp -issuer " . ROOT . "/config/SilverbulletClientCerts/real-".$this->ca_type.".pem -sha1 -ndays 10 -no_nonce -serial 0x$serialHex -CA " . ROOT . "/config/SilverbulletClientCerts/real-".$this->ca_type.".pem -rsigner " . ROOT . "/config/SilverbulletClientCerts/real-".$this->ca_type.".pem -rkey " . ROOT . "/config/SilverbulletClientCerts/real-".$this->ca_type.".key -index $tempdir/index.txt -no_cert_verify -respout $tempdir/$serialHex.response.der";
317
+                $execCmd = CONFIG['PATHS']['openssl']." ocsp -issuer ".ROOT."/config/SilverbulletClientCerts/real-".$this->ca_type.".pem -sha1 -ndays 10 -no_nonce -serial 0x$serialHex -CA ".ROOT."/config/SilverbulletClientCerts/real-".$this->ca_type.".pem -rsigner ".ROOT."/config/SilverbulletClientCerts/real-".$this->ca_type.".pem -rkey ".ROOT."/config/SilverbulletClientCerts/real-".$this->ca_type.".key -index $tempdir/index.txt -no_cert_verify -respout $tempdir/$serialHex.response.der";
318 318
                 $logHandle->debug(2, "Calling openssl ocsp with following cmdline: $execCmd\n");
319 319
                 $output = [];
320 320
                 $return = 999;
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
                 if ($return !== 0) {
323 323
                     throw new Exception("Non-zero return value from openssl ocsp!");
324 324
                 }
325
-                $ocsp = file_get_contents($tempdir . "/$serialHex.response.der");
325
+                $ocsp = file_get_contents($tempdir."/$serialHex.response.der");
326 326
                 // remove the temp dir!
327
-                unlink($tempdir . "/$serialHex.response.der");
328
-                unlink($tempdir . "/index.txt.attr");
329
-                unlink($tempdir . "/index.txt");
327
+                unlink($tempdir."/$serialHex.response.der");
328
+                unlink($tempdir."/index.txt.attr");
329
+                unlink($tempdir."/index.txt");
330 330
                 rmdir($tempdir);
331 331
                 break;
332 332
             default:
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
         $username = "";
381 381
         while ($usernameIsUnique === FALSE) {
382 382
             $usernameLocalPart = common\Entity::randomString(64 - 1 - strlen($realm), "0123456789abcdefghijklmnopqrstuvwxyz");
383
-            $username = $usernameLocalPart . "@" . $realm;
383
+            $username = $usernameLocalPart."@".$realm;
384 384
             $uniquenessQuery = $databaseHandle->exec("SELECT cn from silverbullet_certificate WHERE cn = ?", "s", $username);
385 385
             // SELECT -> resource, not boolean
386 386
             if (mysqli_num_rows(/** @scrutinizer ignore-type */ $uniquenessQuery) == 0) {
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
         $databaseHandle = DBConnection::handle("INST");
433 433
         switch (CONFIG_CONFASSISTANT['SILVERBULLET']['CA']['type']) {
434 434
             case "embedded":
435
-                $rootCaPem = file_get_contents(ROOT . "/config/SilverbulletClientCerts/rootca-$certtype.pem");
436
-                $issuingCaPem = file_get_contents(ROOT . "/config/SilverbulletClientCerts/real-$certtype.pem");
435
+                $rootCaPem = file_get_contents(ROOT."/config/SilverbulletClientCerts/rootca-$certtype.pem");
436
+                $issuingCaPem = file_get_contents(ROOT."/config/SilverbulletClientCerts/real-$certtype.pem");
437 437
                 $issuingCa = openssl_x509_read($issuingCaPem);
438
-                $issuingCaKey = openssl_pkey_get_private("file://" . ROOT . "/config/SilverbulletClientCerts/real-$certtype.key");
438
+                $issuingCaKey = openssl_pkey_get_private("file://".ROOT."/config/SilverbulletClientCerts/real-$certtype.key");
439 439
                 $nonDupSerialFound = FALSE;
440 440
                 do {
441 441
                     $serial = random_int(1000000000, PHP_INT_MAX);
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
                         throw new Exception("Unknown cert type!");
458 458
                 }
459 459
                 return [
460
-                    "CERT" => openssl_csr_sign($csr, $issuingCa, $issuingCaKey, $expiryDays, ['digest_alg' => $alg, 'config' => dirname(__DIR__) . "/config/SilverbulletClientCerts/openssl-$certtype.cnf"], $serial),
460
+                    "CERT" => openssl_csr_sign($csr, $issuingCa, $issuingCaKey, $expiryDays, ['digest_alg' => $alg, 'config' => dirname(__DIR__)."/config/SilverbulletClientCerts/openssl-$certtype.cnf"], $serial),
461 461
                     "SERIAL" => $serial,
462 462
                     "ISSUER" => $issuingCaPem,
463 463
                     "ROOT" => $rootCaPem,
Please login to merge, or discard this patch.