@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class CertificationAuthorityEmbeddedRSA extends EntityWithDBProperties implements CertificationAuthorityInterface { |
| 15 | 15 | |
| 16 | - private const LOCATION_ROOT_CA = ROOT . "/config/SilverbulletClientCerts/rootca-RSA.pem"; |
|
| 17 | - private const LOCATION_ISSUING_CA = ROOT . "/config/SilverbulletClientCerts/real-RSA.pem"; |
|
| 18 | - private const LOCATION_ISSUING_KEY = ROOT . "/config/SilverbulletClientCerts/real-RSA.key"; |
|
| 19 | - private const LOCATION_CONFIG = ROOT . "/config/SilverbulletClientCerts/openssl-RSA.cnf"; |
|
| 16 | + private const LOCATION_ROOT_CA = ROOT."/config/SilverbulletClientCerts/rootca-RSA.pem"; |
|
| 17 | + private const LOCATION_ISSUING_CA = ROOT."/config/SilverbulletClientCerts/real-RSA.pem"; |
|
| 18 | + private const LOCATION_ISSUING_KEY = ROOT."/config/SilverbulletClientCerts/real-RSA.key"; |
|
| 19 | + private const LOCATION_CONFIG = ROOT."/config/SilverbulletClientCerts/openssl-RSA.cnf"; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * string with the PEM variant of the root CA |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | parent::__construct(); |
| 58 | 58 | $this->rootPem = file_get_contents(CertificationAuthorityEmbeddedRSA::LOCATION_ROOT_CA); |
| 59 | 59 | if ($this->rootPem === FALSE) { |
| 60 | - throw new Exception("Root CA PEM file not found: " . CertificationAuthorityEmbeddedRSA::LOCATION_ROOT_CA); |
|
| 60 | + throw new Exception("Root CA PEM file not found: ".CertificationAuthorityEmbeddedRSA::LOCATION_ROOT_CA); |
|
| 61 | 61 | } |
| 62 | 62 | $this->issuingCertRaw = file_get_contents(CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA); |
| 63 | 63 | if ($this->issuingCertRaw === FALSE) { |
| 64 | - throw new Exception("Issuing CA PEM file not found: " . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA); |
|
| 64 | + throw new Exception("Issuing CA PEM file not found: ".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA); |
|
| 65 | 65 | } |
| 66 | 66 | $rootParsed = openssl_x509_read($this->rootPem); |
| 67 | 67 | $this->issuingCert = openssl_x509_read($this->issuingCertRaw); |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | throw new Exception("At least one CA PEM file did not parse correctly!"); |
| 70 | 70 | } |
| 71 | 71 | if (stat(CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY) === FALSE) { |
| 72 | - throw new Exception("Private key not found: " . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY); |
|
| 72 | + throw new Exception("Private key not found: ".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY); |
|
| 73 | 73 | } |
| 74 | - $this->issuingKey = openssl_pkey_get_private("file://" . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY); |
|
| 74 | + $this->issuingKey = openssl_pkey_get_private("file://".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY); |
|
| 75 | 75 | if ($this->issuingKey === FALSE) { |
| 76 | 76 | throw new Exception("The private key did not parse correctly!"); |
| 77 | 77 | } |
| 78 | 78 | if (stat(CertificationAuthorityEmbeddedRSA::LOCATION_CONFIG) === FALSE) { |
| 79 | - throw new Exception("openssl configuration not found: " . CertificationAuthorityEmbeddedRSA::LOCATION_CONFIG); |
|
| 79 | + throw new Exception("openssl configuration not found: ".CertificationAuthorityEmbeddedRSA::LOCATION_CONFIG); |
|
| 80 | 80 | } |
| 81 | 81 | $this->conffile = CertificationAuthorityEmbeddedRSA::LOCATION_CONFIG; |
| 82 | 82 | } |
@@ -109,26 +109,26 @@ discard block |
||
| 109 | 109 | // generate stub index.txt file |
| 110 | 110 | $tempdirArray = \core\common\Entity::createTemporaryDirectory("test"); |
| 111 | 111 | $tempdir = $tempdirArray['dir']; |
| 112 | - $nowIndexTxt = (new \DateTime())->format("ymdHis") . "Z"; |
|
| 113 | - $expiryIndexTxt = $originalExpiry->format("ymdHis") . "Z"; |
|
| 112 | + $nowIndexTxt = (new \DateTime())->format("ymdHis")."Z"; |
|
| 113 | + $expiryIndexTxt = $originalExpiry->format("ymdHis")."Z"; |
|
| 114 | 114 | $serialHex = strtoupper(dechex($cert->serial)); |
| 115 | 115 | if (strlen($serialHex) % 2 == 1) { |
| 116 | - $serialHex = "0" . $serialHex; |
|
| 116 | + $serialHex = "0".$serialHex; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $indexStatement = "$certstatus\t$expiryIndexTxt\t" . ($certstatus == "R" ? "$nowIndexTxt,unspecified" : "") . "\t$serialHex\tunknown\t/O=" . CONFIG_CONFASSISTANT['CONSORTIUM']['name'] . "/OU=$federation/CN=$cert->username\n"; |
|
| 119 | + $indexStatement = "$certstatus\t$expiryIndexTxt\t".($certstatus == "R" ? "$nowIndexTxt,unspecified" : "")."\t$serialHex\tunknown\t/O=".CONFIG_CONFASSISTANT['CONSORTIUM']['name']."/OU=$federation/CN=$cert->username\n"; |
|
| 120 | 120 | $this->loggerInstance->debug(4, "index.txt contents-to-be: $indexStatement"); |
| 121 | - if (!file_put_contents($tempdir . "/index.txt", $indexStatement)) { |
|
| 121 | + if (!file_put_contents($tempdir."/index.txt", $indexStatement)) { |
|
| 122 | 122 | $this->loggerInstance->debug(1, "Unable to write openssl index.txt file for revocation handling!"); |
| 123 | 123 | } |
| 124 | 124 | // index.txt.attr is dull but needs to exist |
| 125 | - file_put_contents($tempdir . "/index.txt.attr", "unique_subject = yes\n"); |
|
| 125 | + file_put_contents($tempdir."/index.txt.attr", "unique_subject = yes\n"); |
|
| 126 | 126 | // call "openssl ocsp" to manufacture our own OCSP statement |
| 127 | 127 | // adding "-rmd sha1" to the following command-line makes the |
| 128 | 128 | // choice of signature algorithm for the response explicit |
| 129 | 129 | // but it's only available from openssl-1.1.0 (which we do not |
| 130 | 130 | // want to require just for that one thing). |
| 131 | - $execCmd = CONFIG['PATHS']['openssl'] . " ocsp -issuer " . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA . " -sha1 -ndays 10 -no_nonce -serial 0x$serialHex -CA " . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA . " -rsigner " . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA . " -rkey " . CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY . " -index $tempdir/index.txt -no_cert_verify -respout $tempdir/$serialHex.response.der"; |
|
| 131 | + $execCmd = CONFIG['PATHS']['openssl']." ocsp -issuer ".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA." -sha1 -ndays 10 -no_nonce -serial 0x$serialHex -CA ".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA." -rsigner ".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_CA." -rkey ".CertificationAuthorityEmbeddedRSA::LOCATION_ISSUING_KEY." -index $tempdir/index.txt -no_cert_verify -respout $tempdir/$serialHex.response.der"; |
|
| 132 | 132 | $this->loggerInstance->debug(2, "Calling openssl ocsp with following cmdline: $execCmd\n"); |
| 133 | 133 | $output = []; |
| 134 | 134 | $return = 999; |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | if ($return !== 0) { |
| 137 | 137 | throw new Exception("Non-zero return value from openssl ocsp!"); |
| 138 | 138 | } |
| 139 | - $ocsp = file_get_contents($tempdir . "/$serialHex.response.der"); |
|
| 139 | + $ocsp = file_get_contents($tempdir."/$serialHex.response.der"); |
|
| 140 | 140 | // remove the temp dir! |
| 141 | - unlink($tempdir . "/$serialHex.response.der"); |
|
| 142 | - unlink($tempdir . "/index.txt.attr"); |
|
| 143 | - unlink($tempdir . "/index.txt"); |
|
| 141 | + unlink($tempdir."/$serialHex.response.der"); |
|
| 142 | + unlink($tempdir."/index.txt.attr"); |
|
| 143 | + unlink($tempdir."/index.txt"); |
|
| 144 | 144 | rmdir($tempdir); |
| 145 | 145 | $this->databaseHandle->exec("UPDATE silverbullet_certificate SET OCSP = ?, OCSP_timestamp = NOW() WHERE serial_number = ?", "si", $ocsp, $cert->serial); |
| 146 | 146 | return $ocsp; |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | * @return CertificationAuthorityInterface engine to use |
| 164 | 164 | */ |
| 165 | 165 | public static function getCaEngine($type) { |
| 166 | - switch ($type) { |
|
| 166 | + switch ($type) { |
|
| 167 | 167 | case \devices\Devices::SUPPORT_EMBEDDED_RSA: |
| 168 | 168 | $privateKey = openssl_pkey_new(['private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA, 'encrypt_key' => FALSE]); |
| 169 | 169 | $caEngine = new CertificationAuthorityEmbeddedRSA(); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $invitationObject = new SilverbulletInvitation($token); |
| 196 | 196 | $profile = new ProfileSilverbullet($invitationObject->profile); |
| 197 | 197 | $inst = new IdP($profile->institution); |
| 198 | - $loggerInstance->debug(5, "tokenStatus: done, got " . $invitationObject->invitationTokenStatus . ", " . $invitationObject->profile . ", " . $invitationObject->userId . ", " . $invitationObject->expiry . ", " . $invitationObject->invitationTokenString . "\n"); |
|
| 198 | + $loggerInstance->debug(5, "tokenStatus: done, got ".$invitationObject->invitationTokenStatus.", ".$invitationObject->profile.", ".$invitationObject->userId.", ".$invitationObject->expiry.", ".$invitationObject->invitationTokenString."\n"); |
|
| 199 | 199 | if ($invitationObject->invitationTokenStatus != SilverbulletInvitation::SB_TOKENSTATUS_VALID && $invitationObject->invitationTokenStatus != SilverbulletInvitation::SB_TOKENSTATUS_PARTIALLY_REDEEMED) { |
| 200 | 200 | throw new Exception("Attempt to generate a SilverBullet installer with an invalid/redeemed/expired token. The user should never have gotten that far!"); |
| 201 | 201 | } |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | throw new Exception("Despite a valid token, the corresponding user was not found in database or database query error!"); |
| 209 | 209 | } |
| 210 | 210 | $expiryObject = mysqli_fetch_object(/** @scrutinizer ignore-type */ $userrow); |
| 211 | - $loggerInstance->debug(5, "EXP: " . $expiryObject->expiry . "\n"); |
|
| 211 | + $loggerInstance->debug(5, "EXP: ".$expiryObject->expiry."\n"); |
|
| 212 | 212 | $expiryDateObject = date_create_from_format("Y-m-d H:i:s", $expiryObject->expiry); |
| 213 | 213 | if ($expiryDateObject === FALSE) { |
| 214 | 214 | throw new Exception("The expiry date we got from the DB is bogus!"); |
| 215 | 215 | } |
| 216 | - $loggerInstance->debug(5, $expiryDateObject->format("Y-m-d H:i:s") . "\n"); |
|
| 216 | + $loggerInstance->debug(5, $expiryDateObject->format("Y-m-d H:i:s")."\n"); |
|
| 217 | 217 | // date_create with no parameters can't fail, i.e. is never FALSE |
| 218 | 218 | $validity = date_diff(/** @scrutinizer ignore-type */ date_create(), $expiryDateObject); |
| 219 | 219 | $expiryDays = $validity->days + 1; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $certString = ""; |
| 252 | 252 | openssl_x509_export($cert, $certString); |
| 253 | 253 | $parsedCert = $x509->processCertificate($certString); |
| 254 | - $loggerInstance->debug(5, "CERTINFO: " . print_r($parsedCert['full_details'], true)); |
|
| 254 | + $loggerInstance->debug(5, "CERTINFO: ".print_r($parsedCert['full_details'], true)); |
|
| 255 | 255 | $realExpiryDate = date_create_from_format("U", $parsedCert['full_details']['validTo_time_t'])->format("Y-m-d H:i:s"); |
| 256 | 256 | |
| 257 | 257 | // store new cert info in DB |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $username = ""; |
| 299 | 299 | while ($usernameIsUnique === FALSE) { |
| 300 | 300 | $usernameLocalPart = common\Entity::randomString(64 - 1 - strlen($realm), "0123456789abcdefghijklmnopqrstuvwxyz"); |
| 301 | - $username = $usernameLocalPart . "@" . $realm; |
|
| 301 | + $username = $usernameLocalPart."@".$realm; |
|
| 302 | 302 | $uniquenessQuery = $databaseHandle->exec("SELECT cn from silverbullet_certificate WHERE cn = ? AND ca_type = ?", "ss", $username, $certtype); |
| 303 | 303 | // SELECT -> resource, not boolean |
| 304 | 304 | if (mysqli_num_rows(/** @scrutinizer ignore-type */ $uniquenessQuery) == 0) { |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class CertificationAuthorityEduPki extends EntityWithDBProperties implements CertificationAuthorityInterface { |
| 15 | 15 | |
| 16 | - private const LOCATION_RA_CERT = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
| 17 | - private const LOCATION_RA_KEY = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey"; |
|
| 18 | - private const LOCATION_WEBROOT = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
| 16 | + private const LOCATION_RA_CERT = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
| 17 | + private const LOCATION_RA_KEY = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey"; |
|
| 18 | + private const LOCATION_WEBROOT = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
| 19 | 19 | private const EDUPKI_RA_ID = 700; |
| 20 | 20 | private const EDUPKI_CERT_PROFILE = "User SOAP"; |
| 21 | 21 | private const EDUPKI_RA_PKEY_PASSPHRASE = "..."; |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | parent::__construct(); |
| 47 | 47 | |
| 48 | 48 | if (stat(CertificationAuthorityEduPki::LOCATION_RA_CERT) === FALSE) { |
| 49 | - throw new Exception("RA operator PEM file not found: " . CertificationAuthorityEduPki::LOCATION_RA_CERT); |
|
| 49 | + throw new Exception("RA operator PEM file not found: ".CertificationAuthorityEduPki::LOCATION_RA_CERT); |
|
| 50 | 50 | } |
| 51 | 51 | if (stat(CertificationAuthorityEduPki::LOCATION_RA_KEY) === FALSE) { |
| 52 | - throw new Exception("RA operator private key file not found: " . CertificationAuthorityEduPki::LOCATION_RA_KEY); |
|
| 52 | + throw new Exception("RA operator private key file not found: ".CertificationAuthorityEduPki::LOCATION_RA_KEY); |
|
| 53 | 53 | } |
| 54 | 54 | if (stat(CertificationAuthorityEduPki::LOCATION_WEBROOT) === FALSE) { |
| 55 | - throw new Exception("CA website root CA file not found: " . CertificationAuthorityEduPki::LOCATION_WEBROOT); |
|
| 55 | + throw new Exception("CA website root CA file not found: ".CertificationAuthorityEduPki::LOCATION_WEBROOT); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -66,19 +66,19 @@ discard block |
||
| 66 | 66 | // initialise connection to eduPKI CA / eduroam RA and send the request to them |
| 67 | 67 | try { |
| 68 | 68 | $altArray = [# Array mit den Subject Alternative Names |
| 69 | - "email:" . $csr["USERNAME"] |
|
| 69 | + "email:".$csr["USERNAME"] |
|
| 70 | 70 | ]; |
| 71 | 71 | $soapPub = $this->initEduPKISoapSession("PUBLIC"); |
| 72 | 72 | $this->loggerInstance->debug(5, "FIRST ACTUAL SOAP REQUEST (Public, newRequest)!\n"); |
| 73 | - $this->loggerInstance->debug(5, "PARAM_1: " . SilverbulletCertificate::EDUPKI_RA_ID . "\n"); |
|
| 74 | - $this->loggerInstance->debug(5, "PARAM_2: " . $csr["CSR"] . "\n"); |
|
| 73 | + $this->loggerInstance->debug(5, "PARAM_1: ".SilverbulletCertificate::EDUPKI_RA_ID."\n"); |
|
| 74 | + $this->loggerInstance->debug(5, "PARAM_2: ".$csr["CSR"]."\n"); |
|
| 75 | 75 | $this->loggerInstance->debug(5, "PARAM_3: "); |
| 76 | 76 | $this->loggerInstance->debug(5, $altArray); |
| 77 | - $this->loggerInstance->debug(5, "PARAM_4: " . SilverbulletCertificate::EDUPKI_CERT_PROFILE . "\n"); |
|
| 78 | - $this->loggerInstance->debug(5, "PARAM_5: " . sha1("notused") . "\n"); |
|
| 79 | - $this->loggerInstance->debug(5, "PARAM_6: " . $csr["USERNAME"] . "\n"); |
|
| 80 | - $this->loggerInstance->debug(5, "PARAM_7: " . $csr["USERNAME"] . "\n"); |
|
| 81 | - $this->loggerInstance->debug(5, "PARAM_8: " . ProfileSilverbullet::PRODUCTNAME . "\n"); |
|
| 77 | + $this->loggerInstance->debug(5, "PARAM_4: ".SilverbulletCertificate::EDUPKI_CERT_PROFILE."\n"); |
|
| 78 | + $this->loggerInstance->debug(5, "PARAM_5: ".sha1("notused")."\n"); |
|
| 79 | + $this->loggerInstance->debug(5, "PARAM_6: ".$csr["USERNAME"]."\n"); |
|
| 80 | + $this->loggerInstance->debug(5, "PARAM_7: ".$csr["USERNAME"]."\n"); |
|
| 81 | + $this->loggerInstance->debug(5, "PARAM_8: ".ProfileSilverbullet::PRODUCTNAME."\n"); |
|
| 82 | 82 | $this->loggerInstance->debug(5, "PARAM_9: false\n"); |
| 83 | 83 | $soapNewRequest = $soapPub->newRequest( |
| 84 | 84 | SilverbulletCertificate::EDUPKI_RA_ID, # RA-ID |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | } catch (Exception $e) { |
| 101 | 101 | // PHP 7.1 can do this much better |
| 102 | 102 | if (is_soap_fault($e)) { |
| 103 | - throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: { |
|
| 103 | + throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: { |
|
| 104 | 104 | $e->faultstring |
| 105 | 105 | }\n"); |
| 106 | 106 | } |
| 107 | - throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage()); |
|
| 107 | + throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage()); |
|
| 108 | 108 | } |
| 109 | 109 | try { |
| 110 | 110 | $soap = SilverbulletCertificate::initEduPKISoapSession("RA"); |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | $soapReqnum, [ |
| 117 | 117 | "RaID" => SilverbulletCertificate::EDUPKI_RA_ID, |
| 118 | 118 | "Role" => SilverbulletCertificate::EDUPKI_CERT_PROFILE, |
| 119 | - "Subject" => "DC=eduroam,DC=test,DC=test,C=" . $csr["FED"] . ",O=" . CONFIG_CONFASSISTANT['CONSORTIUM']['name'] . ",OU=" . $csr["FED"] . ",CN=" . $csr['USERNAME'] . ",emailAddress=" . $csr['USERNAME'], |
|
| 120 | - "SubjectAltNames" => ["email:" . $csr["USERNAME"]], |
|
| 119 | + "Subject" => "DC=eduroam,DC=test,DC=test,C=".$csr["FED"].",O=".CONFIG_CONFASSISTANT['CONSORTIUM']['name'].",OU=".$csr["FED"].",CN=".$csr['USERNAME'].",emailAddress=".$csr['USERNAME'], |
|
| 120 | + "SubjectAltNames" => ["email:".$csr["USERNAME"]], |
|
| 121 | 121 | "NotBefore" => (new \DateTime())->format('c'), |
| 122 | 122 | "NotAfter" => $expiry->format('c'), |
| 123 | 123 | ] |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file |
| 137 | 137 | // rather than just using the string. Grr. |
| 138 | 138 | $tempdir = \core\common\Entity::createTemporaryDirectory("test"); |
| 139 | - file_put_contents($tempdir['dir'] . "/content.txt", $soapCleartext); |
|
| 139 | + file_put_contents($tempdir['dir']."/content.txt", $soapCleartext); |
|
| 140 | 140 | // retrieve our RA cert from filesystem |
| 141 | 141 | // the RA certificates are not needed right now because we |
| 142 | 142 | // have resorted to S/MIME signatures with openssl command-line |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | // sign the data, using cmdline because openssl_pkcs7_sign produces strange results |
| 149 | 149 | // -binary didn't help, nor switch -md to sha1 sha256 or sha512 |
| 150 | 150 | $this->loggerInstance->debug(5, "Actual content to be signed is this:\n $soapCleartext\n"); |
| 151 | - $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"; |
|
| 151 | + $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"; |
|
| 152 | 152 | $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n"); |
| 153 | 153 | $output = []; |
| 154 | 154 | $return = 999; |
@@ -157,14 +157,14 @@ discard block |
||
| 157 | 157 | throw new Exception("Non-zero return value from openssl smime!"); |
| 158 | 158 | } |
| 159 | 159 | // and get the signature blob back from the filesystem |
| 160 | - $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt")); |
|
| 160 | + $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt")); |
|
| 161 | 161 | $this->loggerInstance->debug(5, "Request for server approveRequest has parameters:\n"); |
| 162 | - $this->loggerInstance->debug(5, $soapReqnum . "\n"); |
|
| 163 | - $this->loggerInstance->debug(5, $soapCleartext . "\n"); // PHP magically encodes this as base64 while sending! |
|
| 164 | - $this->loggerInstance->debug(5, $detachedSig . "\n"); |
|
| 162 | + $this->loggerInstance->debug(5, $soapReqnum."\n"); |
|
| 163 | + $this->loggerInstance->debug(5, $soapCleartext."\n"); // PHP magically encodes this as base64 while sending! |
|
| 164 | + $this->loggerInstance->debug(5, $detachedSig."\n"); |
|
| 165 | 165 | $soapIssueCert = $soap->approveRequest($soapReqnum, $soapCleartext, $detachedSig); |
| 166 | - $this->loggerInstance->debug(5, "approveRequest Request was: \n" . $soap->__getLastRequest()); |
|
| 167 | - $this->loggerInstance->debug(5, "approveRequest Response was: \n" . $soap->__getLastResponse()); |
|
| 166 | + $this->loggerInstance->debug(5, "approveRequest Request was: \n".$soap->__getLastRequest()); |
|
| 167 | + $this->loggerInstance->debug(5, "approveRequest Response was: \n".$soap->__getLastResponse()); |
|
| 168 | 168 | if ($soapIssueCert === FALSE) { |
| 169 | 169 | throw new Exception("The locally approved request was NOT processed by the CA."); |
| 170 | 170 | } |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | throw new Exception("CAInfo has no root certificate for us!"); |
| 202 | 202 | } |
| 203 | 203 | } catch (SoapFault $e) { |
| 204 | - throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
| 204 | + throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
| 205 | 205 | } catch (Exception $e) { |
| 206 | - throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage()); |
|
| 206 | + throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage()); |
|
| 207 | 207 | } |
| 208 | 208 | return [ |
| 209 | 209 | "CERT" => openssl_x509_read($parsedCert['pem']), |
@@ -228,12 +228,12 @@ discard block |
||
| 228 | 228 | // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file |
| 229 | 229 | // rather than just using the string. Grr. |
| 230 | 230 | $tempdir = \core\common\Entity::createTemporaryDirectory("test"); |
| 231 | - file_put_contents($tempdir['dir'] . "/content.txt", $soapRawRevRequest); |
|
| 231 | + file_put_contents($tempdir['dir']."/content.txt", $soapRawRevRequest); |
|
| 232 | 232 | // retrieve our RA cert from filesystem |
| 233 | 233 | // sign the data, using cmdline because openssl_pkcs7_sign produces strange results |
| 234 | 234 | // -binary didn't help, nor switch -md to sha1 sha256 or sha512 |
| 235 | 235 | $this->loggerInstance->debug(5, "Actual content to be signed is this:\n$soapRawRevRequest\n"); |
| 236 | - $execCmd = CONFIG['PATHS']['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . CertificationAuthorityEduPki::LOCATION_RA_KEY . " -signer " . CertificationAuthorityEduPki::LOCATION_RA_CERT; |
|
| 236 | + $execCmd = CONFIG['PATHS']['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".CertificationAuthorityEduPki::LOCATION_RA_KEY." -signer ".CertificationAuthorityEduPki::LOCATION_RA_CERT; |
|
| 237 | 237 | $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n"); |
| 238 | 238 | $output = []; |
| 239 | 239 | $return = 999; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | throw new Exception("Non-zero return value from openssl smime!"); |
| 243 | 243 | } |
| 244 | 244 | // and get the signature blob back from the filesystem |
| 245 | - $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt")); |
|
| 245 | + $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt")); |
|
| 246 | 246 | $soapIssueRev = $soap->approveRevocationRequest($soapRevocationSerial, $soapRawRevRequest, $detachedSig); |
| 247 | 247 | if ($soapIssueRev === FALSE) { |
| 248 | 248 | throw new Exception("The locally approved revocation request was NOT processed by the CA."); |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | } catch (Exception $e) { |
| 251 | 251 | // PHP 7.1 can do this much better |
| 252 | 252 | if (is_soap_fault($e)) { |
| 253 | - throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: {$e->faultstring}\n"); |
|
| 253 | + throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: {$e->faultstring}\n"); |
|
| 254 | 254 | } |
| 255 | - throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage()); |
|
| 255 | + throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage()); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
@@ -349,9 +349,9 @@ discard block |
||
| 349 | 349 | * @return string the integer as string in an XML fragment |
| 350 | 350 | */ |
| 351 | 351 | public function soapToXmlInteger($x) { |
| 352 | - return '<' . $x[0] . '>' |
|
| 352 | + return '<'.$x[0].'>' |
|
| 353 | 353 | . htmlentities($x[1], ENT_NOQUOTES | ENT_XML1) |
| 354 | - . '</' . $x[0] . '>'; |
|
| 354 | + . '</'.$x[0].'>'; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | public function generateCompatibleCsr($privateKey, $fed, $username): array { |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | // dump private key into directory |
| 361 | 361 | $outstring = ""; |
| 362 | 362 | openssl_pkey_export($privateKey, $outstring); |
| 363 | - file_put_contents($tempdir . "/pkey.pem", $outstring); |
|
| 363 | + file_put_contents($tempdir."/pkey.pem", $outstring); |
|
| 364 | 364 | // PHP can only do one DC in the Subject. But we need three. |
| 365 | - $execCmd = CONFIG['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"; |
|
| 365 | + $execCmd = CONFIG['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"; |
|
| 366 | 366 | $this->loggerInstance->debug(2, "Calling openssl req with following cmdline: $execCmd\n"); |
| 367 | 367 | $output = []; |
| 368 | 368 | $return = 999; |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | $caEngine->triggerNewOCSPStatement($certObject); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /* |
|
| 46 | + /* |
|
| 47 | 47 | * and then writes all recently updated statements to a temporary directory. The |
| 48 | 48 | * calling script ocsp_update.sh should then scp all the files to their |
| 49 | 49 | * destination. |