Passed
Push — release_2_0 ( 42847d...5cfef1 )
by Stefan
14:05
created
core/CertificationAuthorityEduPkiServer.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
         // initialise connection to eduPKI CA / eduroam RA and send the request to them
69 69
         try {
70 70
             $altArray = [# Array mit den Subject Alternative Names
71
-                 "email:" . $csr["USERMAIL"]
71
+                    "email:" . $csr["USERMAIL"]
72 72
             ];
73 73
             $soapPub = $this->initEduPKISoapSession("PUBLIC");
74 74
             $this->loggerInstance->debug(5, "FIRST ACTUAL SOAP REQUEST (Public, newRequest)!\n");
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 class CertificationAuthorityEduPkiServer extends EntityWithDBProperties implements CertificationAuthorityInterface {
18 18
 
19
-    private const LOCATION_RA_CERT = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem";
20
-    private const LOCATION_RA_KEY = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey";
21
-    private const LOCATION_WEBROOT = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem";
19
+    private const LOCATION_RA_CERT = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem";
20
+    private const LOCATION_RA_KEY = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey";
21
+    private const LOCATION_WEBROOT = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem";
22 22
     private const EDUPKI_RA_ID = 700;
23 23
     private const EDUPKI_CERT_PROFILE = "Radius Server SOAP";
24 24
     private const EDUPKI_RA_PKEY_PASSPHRASE = "...";
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
         parent::__construct();
34 34
 
35 35
         if (stat(CertificationAuthorityEduPkiServer::LOCATION_RA_CERT) === FALSE) {
36
-            throw new Exception("RA operator PEM file not found: " . CertificationAuthorityEduPkiServer::LOCATION_RA_CERT);
36
+            throw new Exception("RA operator PEM file not found: ".CertificationAuthorityEduPkiServer::LOCATION_RA_CERT);
37 37
         }
38 38
         if (stat(CertificationAuthorityEduPkiServer::LOCATION_RA_KEY) === FALSE) {
39
-            throw new Exception("RA operator private key file not found: " . CertificationAuthorityEduPkiServer::LOCATION_RA_KEY);
39
+            throw new Exception("RA operator private key file not found: ".CertificationAuthorityEduPkiServer::LOCATION_RA_KEY);
40 40
         }
41 41
         if (stat(CertificationAuthorityEduPkiServer::LOCATION_WEBROOT) === FALSE) {
42
-            throw new Exception("CA website root CA file not found: " . CertificationAuthorityEduPkiServer::LOCATION_WEBROOT);
42
+            throw new Exception("CA website root CA file not found: ".CertificationAuthorityEduPkiServer::LOCATION_WEBROOT);
43 43
         }
44 44
     }
45 45
 
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
         // initialise connection to eduPKI CA / eduroam RA and send the request to them
69 69
         try {
70 70
             $altArray = [# Array mit den Subject Alternative Names
71
-                 "email:" . $csr["USERMAIL"]
71
+                 "email:".$csr["USERMAIL"]
72 72
             ];
73 73
             $soapPub = $this->initEduPKISoapSession("PUBLIC");
74 74
             $this->loggerInstance->debug(5, "FIRST ACTUAL SOAP REQUEST (Public, newRequest)!\n");
75
-            $this->loggerInstance->debug(5, "PARAM_1: " . CertificationAuthorityEduPkiServer::EDUPKI_RA_ID . "\n");
76
-            $this->loggerInstance->debug(5, "PARAM_2: " . $csr["CSR"] . "\n");
75
+            $this->loggerInstance->debug(5, "PARAM_1: ".CertificationAuthorityEduPkiServer::EDUPKI_RA_ID."\n");
76
+            $this->loggerInstance->debug(5, "PARAM_2: ".$csr["CSR"]."\n");
77 77
             $this->loggerInstance->debug(5, "PARAM_3: ");
78 78
             $this->loggerInstance->debug(5, $altArray);
79
-            $this->loggerInstance->debug(5, "PARAM_4: " . CertificationAuthorityEduPkiServer::EDUPKI_CERT_PROFILE . "\n");
80
-            $this->loggerInstance->debug(5, "PARAM_5: " . sha1("notused") . "\n");
81
-            $this->loggerInstance->debug(5, "PARAM_6: " . $csr["USERNAME"] . "\n");
82
-            $this->loggerInstance->debug(5, "PARAM_7: " . $csr["USERMAIL"] . "\n");
83
-            $this->loggerInstance->debug(5, "PARAM_8: " . ProfileSilverbullet::PRODUCTNAME . "\n");
79
+            $this->loggerInstance->debug(5, "PARAM_4: ".CertificationAuthorityEduPkiServer::EDUPKI_CERT_PROFILE."\n");
80
+            $this->loggerInstance->debug(5, "PARAM_5: ".sha1("notused")."\n");
81
+            $this->loggerInstance->debug(5, "PARAM_6: ".$csr["USERNAME"]."\n");
82
+            $this->loggerInstance->debug(5, "PARAM_7: ".$csr["USERMAIL"]."\n");
83
+            $this->loggerInstance->debug(5, "PARAM_8: ".ProfileSilverbullet::PRODUCTNAME."\n");
84 84
             $this->loggerInstance->debug(5, "PARAM_9: false\n");
85 85
             $soapNewRequest = $soapPub->newRequest(
86 86
                     CertificationAuthorityEduPkiServer::EDUPKI_RA_ID, # RA-ID
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
         } catch (Exception $e) {
103 103
             // PHP 7.1 can do this much better
104 104
             if (is_soap_fault($e)) {
105
-                throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}:  {
105
+                throw new Exception("Error when sending SOAP request: "."{$e->faultcode}:  {
106 106
                     $e->faultstring
107 107
                 }\n");
108 108
             }
109
-            throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage());
109
+            throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage());
110 110
         }
111 111
         try {
112 112
             $soap = $this->initEduPKISoapSession("RA");
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file
142 142
             // rather than just using the string. Grr.
143 143
             $tempdir = \core\common\Entity::createTemporaryDirectory("test");
144
-            file_put_contents($tempdir['dir'] . "/content.txt", $soapCleartext);
144
+            file_put_contents($tempdir['dir']."/content.txt", $soapCleartext);
145 145
             // retrieve our RA cert from filesystem                    
146 146
             // the RA certificates are not needed right now because we
147 147
             // have resorted to S/MIME signatures with openssl command-line
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             // sign the data, using cmdline because openssl_pkcs7_sign produces strange results
154 154
             // -binary didn't help, nor switch -md to sha1 sha256 or sha512
155 155
             $this->loggerInstance->debug(5, "Actual content to be signed is this:\n  $soapCleartext\n");
156
-            $execCmd = CONFIG['PATHS']['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey -signer " . ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem";
156
+            $execCmd = CONFIG['PATHS']['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey -signer ".ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem";
157 157
             $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline:   $execCmd\n");
158 158
             $output = [];
159 159
             $return = 999;
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
                 throw new Exception("Non-zero return value from openssl smime!");
163 163
             }
164 164
             // and get the signature blob back from the filesystem
165
-            $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt"));
165
+            $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt"));
166 166
             $this->loggerInstance->debug(5, "Request for server approveRequest has parameters:\n");
167
-            $this->loggerInstance->debug(5, $soapReqnum . "\n");
168
-            $this->loggerInstance->debug(5, $soapCleartext . "\n"); // PHP magically encodes this as base64 while sending!
169
-            $this->loggerInstance->debug(5, $detachedSig . "\n");
167
+            $this->loggerInstance->debug(5, $soapReqnum."\n");
168
+            $this->loggerInstance->debug(5, $soapCleartext."\n"); // PHP magically encodes this as base64 while sending!
169
+            $this->loggerInstance->debug(5, $detachedSig."\n");
170 170
             $soapIssueCert = $soap->approveRequest($soapReqnum, $soapCleartext, $detachedSig);
171
-            $this->loggerInstance->debug(5, "approveRequest Request was: \n" . $soap->__getLastRequest());
172
-            $this->loggerInstance->debug(5, "approveRequest Response was: \n" . $soap->__getLastResponse());
171
+            $this->loggerInstance->debug(5, "approveRequest Request was: \n".$soap->__getLastRequest());
172
+            $this->loggerInstance->debug(5, "approveRequest Response was: \n".$soap->__getLastResponse());
173 173
             if ($soapIssueCert === FALSE) {
174 174
                 throw new Exception("The locally approved request was NOT processed by the CA.");
175 175
             }
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
                 throw new Exception("CAInfo has no root certificate for us!");
207 207
             }
208 208
         } catch (SoapFault $e) {
209
-            throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n");
209
+            throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n");
210 210
         } catch (Exception $e) {
211
-            throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage());
211
+            throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage());
212 212
         }
213 213
         return [
214 214
             "CERT" => openssl_x509_read($parsedCert['pem']),
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
             // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file
241 241
             // rather than just using the string. Grr.
242 242
             $tempdir = \core\common\Entity::createTemporaryDirectory("test");
243
-            file_put_contents($tempdir['dir'] . "/content.txt", $soapRawRevRequest);
243
+            file_put_contents($tempdir['dir']."/content.txt", $soapRawRevRequest);
244 244
             // retrieve our RA cert from filesystem
245 245
             // sign the data, using cmdline because openssl_pkcs7_sign produces strange results
246 246
             // -binary didn't help, nor switch -md to sha1 sha256 or sha512
247 247
             $this->loggerInstance->debug(5, "Actual content to be signed is this:\n$soapRawRevRequest\n");
248
-            $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . CertificationAuthorityEduPkiServer::LOCATION_RA_KEY . " -signer " . CertificationAuthorityEduPkiServer::LOCATION_RA_CERT;
248
+            $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".CertificationAuthorityEduPkiServer::LOCATION_RA_KEY." -signer ".CertificationAuthorityEduPkiServer::LOCATION_RA_CERT;
249 249
             $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n");
250 250
             $output = [];
251 251
             $return = 999;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                 throw new Exception("Non-zero return value from openssl smime!");
255 255
             }
256 256
             // and get the signature blob back from the filesystem
257
-            $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt"));
257
+            $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt"));
258 258
             $soapIssueRev = $soap->approveRevocationRequest($soapRevocationSerial, $soapRawRevRequest, $detachedSig);
259 259
             if ($soapIssueRev === FALSE) {
260 260
                 throw new Exception("The locally approved revocation request was NOT processed by the CA.");
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
         } catch (Exception $e) {
263 263
             // PHP 7.1 can do this much better
264 264
             if (is_soap_fault($e)) {
265
-                throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: {$e->faultstring}\n");
265
+                throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: {$e->faultstring}\n");
266 266
             }
267
-            throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage());
267
+            throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage());
268 268
         }
269 269
     }
270 270
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
      * @return string the integer as string in an XML fragment
362 362
      */
363 363
     public function soapToXmlInteger($x) {
364
-        return '<' . $x[0] . '>'
364
+        return '<'.$x[0].'>'
365 365
                 . htmlentities($x[1], ENT_NOQUOTES | ENT_XML1)
366
-                . '</' . $x[0] . '>';
366
+                . '</'.$x[0].'>';
367 367
     }
368 368
 
369 369
     /**
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
         // dump private key into directory
382 382
         $outstring = "";
383 383
         openssl_pkey_export($privateKey, $outstring);
384
-        file_put_contents($tempdir . "/pkey.pem", $outstring);
384
+        file_put_contents($tempdir."/pkey.pem", $outstring);
385 385
         // PHP can only do one DC in the Subject. But we need three.
386
-        $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";
386
+        $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";
387 387
         $this->loggerInstance->debug(2, "Calling openssl req with following cmdline: $execCmd\n");
388 388
         $output = [];
389 389
         $return = 999;
Please login to merge, or discard this patch.
web/admin/action_req_certificate.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 ?>
28 28
 <?php
29
-require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
29
+require_once dirname(dirname(dirname(__FILE__)))."/config/_config.php";
30 30
 
31 31
 $auth = new \web\lib\admin\Authentication();
32 32
 $deco = new \web\lib\admin\PageDecoration();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $fed = $validator->Federation($_POST['NRO-list']);
85 85
                 $country = strtoupper($fed->tld);
86 86
                 $DN[] = "C=$country";
87
-                $DN[] = "O=NRO of " . $cat->knownFederations[strtoupper($fed->tld)];
87
+                $DN[] = "O=NRO of ".$cat->knownFederations[strtoupper($fed->tld)];
88 88
                 $DN[] = "CN=comes.from.eduroam.db";
89 89
                 $policies[] = "eduroam IdP";
90 90
                 $policies[] = "eduroam SP";
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
             default:
105 105
                 throw new Exception("Sorry: Unknown level of issuance requested.");
106 106
         }
107
-        echo "<p>" . _("Requesting a certificate with the following properties");
107
+        echo "<p>"._("Requesting a certificate with the following properties");
108 108
         echo "<ul>";
109
-        echo "<li>" . _("Policy OIDs: ") . implode(", ", $policies) . "</li>";
110
-        echo "<li>" . _("Distinguished Name: ") . implode(", ", $DN) . "</li>";
111
-        echo "<li>" . _("Requester Contact Details: will come from eduroam DB (using stub 'Someone, &lt;[email protected]&gt;').") . "</li>";
109
+        echo "<li>"._("Policy OIDs: ").implode(", ", $policies)."</li>";
110
+        echo "<li>"._("Distinguished Name: ").implode(", ", $DN)."</li>";
111
+        echo "<li>"._("Requester Contact Details: will come from eduroam DB (using stub 'Someone, &lt;[email protected]&gt;').")."</li>";
112 112
         echo "</ul></p>";
113
-        $ossl = proc_open("openssl req -subj '/".implode("/", $DN)."'", [ 0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => [ "file", "/tmp/voodoo-error", "a"] ], $pipes);
113
+        $ossl = proc_open("openssl req -subj '/".implode("/", $DN)."'", [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => ["file", "/tmp/voodoo-error", "a"]], $pipes);
114 114
         if (is_resource($ossl)) {
115 115
             fwrite($pipes[0], $_POST['CSR']);
116 116
             fclose($pipes[0]);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         }
123 123
         echo "<p>"._("This is the new CSR (return code was $retval)")."<pre>$newCsr</pre></p>";
124 124
         echo "<p>"._("Please WAIT. This can take several MINUTES!")."</p>";
125
-        $newCsrWithMeta = ["CSR" => /* $newCsr */ $_POST['CSR'], "CN" => "[email protected]" , "USERNAME" => "Someone", "USERMAIL" => "[email protected]", "SUBJECT" => implode(",", $DN) ,"FED" => $country];
125
+        $newCsrWithMeta = ["CSR" => /* $newCsr */ $_POST['CSR'], "CN" => "[email protected]", "USERNAME" => "Someone", "USERMAIL" => "[email protected]", "SUBJECT" => implode(",", $DN), "FED" => $country];
126 126
         $eduPki = new core\CertificationAuthorityEduPkiServer();
127 127
         // our certs can be good for max 5 years
128 128
         $cert = $eduPki->signRequest($newCsrWithMeta, 1825);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         echo "<p>"._("Here is your certificate:")."<pre>$certPem</pre></p>";
131 131
         ?>
132 132
         <form action="overview_certificates.php" method="GET">
133
-            <button type="submit"><?php echo _("Back to Certificate Overview");?></button>
133
+            <button type="submit"><?php echo _("Back to Certificate Overview"); ?></button>
134 134
         </form>
135 135
     <?php
136 136
     echo $deco->footer();
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
         <?php
145 145
         if (count($feds) == 1) {
146 146
             $fedObject = new \core\Federation($feds[0]['value']);
147
-            echo " <strong>" . $cat->knownFederations[$fedObject->tld] . "</strong>";
148
-            echo '<input type="hidden" name="NRO-list" id="NRO-list" value="' . $fedObject->tld . '"/>';
147
+            echo " <strong>".$cat->knownFederations[$fedObject->tld]."</strong>";
148
+            echo '<input type="hidden" name="NRO-list" id="NRO-list" value="'.$fedObject->tld.'"/>';
149 149
         } else {
150 150
             ?>
151 151
             <select name="NRO-list" id="NRO-list">
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 <?php
154 154
                 foreach ($feds as $oneFed) {
155 155
                     $fedObject = new \core\Federation($oneFed['value']);
156
-                    echo '<option value="' . strtoupper($fedObject->tld) . '">' . $cat->knownFederations[$fedObject->tld] . "</option>";
156
+                    echo '<option value="'.strtoupper($fedObject->tld).'">'.$cat->knownFederations[$fedObject->tld]."</option>";
157 157
                 }
158 158
                 ?>
159 159
             </select>
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 }
174 174
             }
175 175
             foreach ($allIdPs as $id => $name) {
176
-                echo '<option value="' . $id . '">' . $name . "</option>";
176
+                echo '<option value="'.$id.'">'.$name."</option>";
177 177
             }
178 178
             ?>
179 179
         </select>
Please login to merge, or discard this patch.