Test Failed
Push — master ( 56e405...ba52a2 )
by Maja
11:45 queued 12s
created
core/CertificationAuthorityEduPkiServer.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
     public function __construct()
36 36
     {
37 37
             
38
-        if ( \config\ConfAssistant::eduPKI['testing'] === true ) {
39
-            $this->locationRaCert = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem";
40
-            $this->locationRaKey = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey";
41
-            $this->locationWebRoot = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem";
38
+        if (\config\ConfAssistant::eduPKI['testing'] === true) {
39
+            $this->locationRaCert = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem";
40
+            $this->locationRaKey = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey";
41
+            $this->locationWebRoot = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem";
42 42
             $this->eduPkiRaId = 700;
43 43
             $this->eduPkiCertProfileBoth = "Radius Server SOAP";
44 44
             $this->eduPkiCertProfileIdp = "Radius Server SOAP";
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
             $this->eduPkiEndpointPublic = "https://pki.edupki.org/edupki-test-ca/cgi-bin/pub/soap?wsdl=1";
48 48
             $this->eduPkiEndpointRa = "https://ra.edupki.org/edupki-test-ca/cgi-bin/ra/soap?wsdl=1";
49 49
         } else {
50
-            $this->locationRaCert = ROOT . "/config/SilverbulletClientCerts/edupki-prod-ra.pem";
51
-            $this->locationRaKey = ROOT . "/config/SilverbulletClientCerts/edupki-prod-ra.clearkey";
52
-            $this->locationWebRoot = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem";
50
+            $this->locationRaCert = ROOT."/config/SilverbulletClientCerts/edupki-prod-ra.pem";
51
+            $this->locationRaKey = ROOT."/config/SilverbulletClientCerts/edupki-prod-ra.clearkey";
52
+            $this->locationWebRoot = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem";
53 53
             $this->eduPkiRaId = 100;
54 54
             $this->eduPkiCertProfileBoth = "eduroam IdP and SP";
55 55
             $this->eduPkiCertProfileIdp = "eduroam IdP";
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
         parent::__construct();
64 64
 
65 65
         if (stat($this->locationRaCert) === FALSE) {
66
-            throw new Exception("RA operator PEM file not found: " . $this->locationRaCert);
66
+            throw new Exception("RA operator PEM file not found: ".$this->locationRaCert);
67 67
         }
68 68
         if (stat($this->locationRaKey) === FALSE) {
69
-            throw new Exception("RA operator private key file not found: " . $this->locationRaKey);
69
+            throw new Exception("RA operator private key file not found: ".$this->locationRaKey);
70 70
         }
71 71
         if (stat($this->locationWebRoot) === FALSE) {
72
-            throw new Exception("CA website root CA file not found: " . $this->locationWebRoot);
72
+            throw new Exception("CA website root CA file not found: ".$this->locationWebRoot);
73 73
         }
74 74
     }
75 75
 
@@ -136,26 +136,26 @@  discard block
 block discarded – undo
136 136
                 throw new Exception("Unexpected policies requested.");
137 137
             }
138 138
             $altArray = [# Array mit den Subject Alternative Names
139
-                "email:" . $csr["USERMAIL"]
139
+                "email:".$csr["USERMAIL"]
140 140
             ];
141 141
             foreach ($csr["ALTNAMES"] as $oneAltName) {
142 142
                 if (!empty($oneAltName) && preg_match('/(?=^.{1,254}$)(^(?:(?!\d|-)[a-z0-9\-]{1,63}(?<!-)\.)+(?:[a-z]{2,})$)/i', $oneAltName) > 0) {
143
-                    $altArray[] = "DNS:" . $oneAltName;
143
+                    $altArray[] = "DNS:".$oneAltName;
144 144
                 } else {
145
-                    $altArray[] = "IP:" . $oneAltName;
145
+                    $altArray[] = "IP:".$oneAltName;
146 146
                 }
147 147
             }
148 148
             $soapPub = $this->initEduPKISoapSession("PUBLIC");
149 149
             $this->loggerInstance->debug(5, "FIRST ACTUAL SOAP REQUEST (Public, newRequest)!\n");
150
-            $this->loggerInstance->debug(5, "PARAM_1: " . $this->eduPkiRaId . "\n");
151
-            $this->loggerInstance->debug(5, "PARAM_2: " . $csr["CSR_STRING"] . "\n");
150
+            $this->loggerInstance->debug(5, "PARAM_1: ".$this->eduPkiRaId."\n");
151
+            $this->loggerInstance->debug(5, "PARAM_2: ".$csr["CSR_STRING"]."\n");
152 152
             $this->loggerInstance->debug(5, "PARAM_3: ");
153 153
             $this->loggerInstance->debug(5, $altArray);
154
-            $this->loggerInstance->debug(5, "PARAM_4: " . $profile . "\n");
155
-            $this->loggerInstance->debug(5, "PARAM_5: " . sha1("notused") . "\n");
156
-            $this->loggerInstance->debug(5, "PARAM_6: " . $csr["USERNAME"] . "\n");
157
-            $this->loggerInstance->debug(5, "PARAM_7: " . $csr["USERMAIL"] . "\n");
158
-            $this->loggerInstance->debug(5, "PARAM_8: " . ProfileSilverbullet::PRODUCTNAME . "\n");
154
+            $this->loggerInstance->debug(5, "PARAM_4: ".$profile."\n");
155
+            $this->loggerInstance->debug(5, "PARAM_5: ".sha1("notused")."\n");
156
+            $this->loggerInstance->debug(5, "PARAM_6: ".$csr["USERNAME"]."\n");
157
+            $this->loggerInstance->debug(5, "PARAM_7: ".$csr["USERMAIL"]."\n");
158
+            $this->loggerInstance->debug(5, "PARAM_8: ".ProfileSilverbullet::PRODUCTNAME."\n");
159 159
             $this->loggerInstance->debug(5, "PARAM_9: false\n");
160 160
             $soapNewRequest = $soapPub->newRequest(
161 161
                     $this->eduPkiRaId, # RA-ID
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
         } catch (Exception $e) {
178 178
             // PHP 7.1 can do this much better
179 179
             if (is_soap_fault($e)) {
180
-                throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}:  {
180
+                throw new Exception("Error when sending SOAP request: "."{$e->faultcode}:  {
181 181
                     $e->faultstring
182 182
                 }\n");
183 183
             }
184
-            throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage());
184
+            throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage());
185 185
         }
186 186
         try {
187 187
             $soap = $this->initEduPKISoapSession("RA");
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file
214 214
             // rather than just using the string. Grr.
215 215
             $tempdir = \core\common\Entity::createTemporaryDirectory("test");
216
-            file_put_contents($tempdir['dir'] . "/content.txt", $soapCleartext);
216
+            file_put_contents($tempdir['dir']."/content.txt", $soapCleartext);
217 217
             // retrieve our RA cert from filesystem                    
218 218
             // the RA certificates are not needed right now because we
219 219
             // have resorted to S/MIME signatures with openssl command-line
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             // sign the data, using cmdline because openssl_pkcs7_sign produces strange results
226 226
             // -binary didn't help, nor switch -md to sha1 sha256 or sha512
227 227
             $this->loggerInstance->debug(2, "Actual content to be signed is this:\n  $soapCleartext\n");
228
-            $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . $this->locationRaKey . " -signer " . $this->locationRaCert;
228
+            $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".$this->locationRaKey." -signer ".$this->locationRaCert;
229 229
             $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline:   $execCmd\n");
230 230
             $output = [];
231 231
             $return = 999;
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
                 throw new Exception("Non-zero return value from openssl smime!");
235 235
             }
236 236
             // and get the signature blob back from the filesystem
237
-            $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt"));
237
+            $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt"));
238 238
             $this->loggerInstance->debug(5, "Request for server approveRequest has parameters:\n");
239
-            $this->loggerInstance->debug(5, $soapReqnum . "\n");
240
-            $this->loggerInstance->debug(5, $soapCleartext . "\n"); // PHP magically encodes this as base64 while sending!
241
-            $this->loggerInstance->debug(5, $detachedSig . "\n");
239
+            $this->loggerInstance->debug(5, $soapReqnum."\n");
240
+            $this->loggerInstance->debug(5, $soapCleartext."\n"); // PHP magically encodes this as base64 while sending!
241
+            $this->loggerInstance->debug(5, $detachedSig."\n");
242 242
             $soapIssueCert = $soap->approveRequest($soapReqnum, $soapCleartext, $detachedSig);
243
-            $this->loggerInstance->debug(5, "approveRequest Request was: \n" . $soap->__getLastRequest());
244
-            $this->loggerInstance->debug(5, "approveRequest Response was: \n" . $soap->__getLastResponse());
243
+            $this->loggerInstance->debug(5, "approveRequest Request was: \n".$soap->__getLastRequest());
244
+            $this->loggerInstance->debug(5, "approveRequest Response was: \n".$soap->__getLastResponse());
245 245
             if ($soapIssueCert === FALSE) {
246 246
                 throw new Exception("The locally approved request was NOT processed by the CA.");
247 247
             }
248 248
         } catch (SoapFault $e) {
249
-            throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n");
249
+            throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n");
250 250
         } catch (Exception $e) {
251
-            throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage());
251
+            throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage());
252 252
         }
253 253
         return $soapReqnum;
254 254
     }
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
                 throw new Exception("CAInfo has no root certificate for us!");
301 301
             }
302 302
         } catch (SoapFault $e) {
303
-            throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n");
303
+            throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n");
304 304
         } catch (Exception $e) {
305
-            throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage());
305
+            throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage());
306 306
         }
307 307
         return [
308 308
             "CERT" => openssl_x509_read($parsedCert['pem']),
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
             // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file
336 336
             // rather than just using the string. Grr.
337 337
             $tempdir = \core\common\Entity::createTemporaryDirectory("test");
338
-            file_put_contents($tempdir['dir'] . "/content.txt", $soapRawRevRequest);
338
+            file_put_contents($tempdir['dir']."/content.txt", $soapRawRevRequest);
339 339
             // retrieve our RA cert from filesystem
340 340
             // sign the data, using cmdline because openssl_pkcs7_sign produces strange results
341 341
             // -binary didn't help, nor switch -md to sha1 sha256 or sha512
342 342
             $this->loggerInstance->debug(5, "Actual content to be signed is this:\n$soapRawRevRequest\n");
343
-        $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . $this->locationRaKey . " -signer " . $this->locationRaCert;
343
+        $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".$this->locationRaKey." -signer ".$this->locationRaCert;
344 344
             $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n");
345 345
             $output = [];
346 346
             $return = 999;
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 throw new Exception("Non-zero return value from openssl smime!");
350 350
             }
351 351
             // and get the signature blob back from the filesystem
352
-            $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt"));
352
+            $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt"));
353 353
             $soapIssueRev = $soap->approveRevocationRequest($soapRevocationSerial, $soapRawRevRequest, $detachedSig);
354 354
             if ($soapIssueRev === FALSE) {
355 355
                 throw new Exception("The locally approved revocation request was NOT processed by the CA.");
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
         } catch (Exception $e) {
358 358
             // PHP 7.1 can do this much better
359 359
             if (is_soap_fault($e)) {
360
-                throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: {$e->faultstring}\n");
360
+                throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: {$e->faultstring}\n");
361 361
             }
362
-            throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage());
362
+            throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage());
363 363
         }
364 364
     }
365 365
 
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
      */
460 460
     public function soapToXmlInteger($x)
461 461
     {
462
-        return '<' . $x[0] . '>'
462
+        return '<'.$x[0].'>'
463 463
                 . htmlentities($x[1], ENT_NOQUOTES | ENT_XML1)
464
-                . '</' . $x[0] . '>';
464
+                . '</'.$x[0].'>';
465 465
     }
466 466
 
467 467
     /**
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
         // dump private key into directory
481 481
         $outstring = "";
482 482
         openssl_pkey_export($privateKey, $outstring);
483
-        file_put_contents($tempdir . "/pkey.pem", $outstring);
483
+        file_put_contents($tempdir."/pkey.pem", $outstring);
484 484
         // PHP can only do one DC in the Subject. But we need three.
485
-        $execCmd = \config\Master::PATHS['openssl'] . " req -new -sha256 -key $tempdir/pkey.pem -out $tempdir/request.csr -subj /DC=test/DC=test/DC=eduroam/C=$fed/O=" . \config\ConfAssistant::CONSORTIUM['name'] . "/OU=$fed/CN=$username/emailAddress=$username";
485
+        $execCmd = \config\Master::PATHS['openssl']." req -new -sha256 -key $tempdir/pkey.pem -out $tempdir/request.csr -subj /DC=test/DC=test/DC=eduroam/C=$fed/O=".\config\ConfAssistant::CONSORTIUM['name']."/OU=$fed/CN=$username/emailAddress=$username";
486 486
         $this->loggerInstance->debug(2, "Calling openssl req with following cmdline: $execCmd\n");
487 487
         $output = [];
488 488
         $return = 999;
Please login to merge, or discard this patch.