@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | public function testDirectoryPath() { |
29 | 29 | |
30 | - if(!file_exists($this->_directoryPath)) { |
|
30 | + if (!file_exists($this->_directoryPath)) { |
|
31 | 31 | mkdir($this->_directoryPath); |
32 | 32 | } |
33 | 33 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | $account = \LE_ACME2\Account::get($this->_accountEmail); |
12 | 12 | |
13 | - if(\LE_ACME2\Order::exists($account, $this->_orderSubjects)) { |
|
13 | + if (\LE_ACME2\Order::exists($account, $this->_orderSubjects)) { |
|
14 | 14 | $this->markTestSkipped('Skipped: Order does already exist'); |
15 | 15 | } |
16 | 16 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | $account = \LE_ACME2\Account::get($this->_accountEmail); |
26 | 26 | |
27 | - if(\LE_ACME2\Order::exists($account, $this->_orderSubjects)) { |
|
27 | + if (\LE_ACME2\Order::exists($account, $this->_orderSubjects)) { |
|
28 | 28 | // Skipping order modification tests, when the order already exists |
29 | 29 | // to reduce the LE api usage while developing |
30 | 30 | TestHelper::getInstance()->setSkipOrderModificationTests(true); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $account = \LE_ACME2\Account::get($this->_accountEmail); |
51 | 51 | |
52 | - if(\LE_ACME2\Order::exists($account, $this->_umlautsOrderSubjects)) { |
|
52 | + if (\LE_ACME2\Order::exists($account, $this->_umlautsOrderSubjects)) { |
|
53 | 53 | // Skipping order modification tests, when the order already exists |
54 | 54 | // to reduce the LE api usage while developing |
55 | 55 | TestHelper::getInstance()->setSkipOrderModificationTests(true); |
@@ -12,9 +12,9 @@ |
||
12 | 12 | |
13 | 13 | private function __construct() { |
14 | 14 | |
15 | - $projectPath = realpath($_SERVER[ 'PWD' ]) . '/'; |
|
15 | + $projectPath = realpath($_SERVER['PWD']) . '/'; |
|
16 | 16 | $this->_tempPath = $projectPath . 'temp/'; |
17 | - if( !file_exists($this->_tempPath) ) { |
|
17 | + if (!file_exists($this->_tempPath)) { |
|
18 | 18 | mkdir($this->_tempPath); |
19 | 19 | } |
20 | 20 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function testCommonKeyDirectoryPath() { |
31 | 31 | |
32 | - if(!file_exists($this->_commonKeyDirectoryPath)) { |
|
32 | + if (!file_exists($this->_commonKeyDirectoryPath)) { |
|
33 | 33 | mkdir($this->_commonKeyDirectoryPath); |
34 | 34 | } |
35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function testNonExisting() { |
44 | 44 | |
45 | - if(\LE_ACME2\Account::exists($this->_accountEmail)) { |
|
45 | + if (\LE_ACME2\Account::exists($this->_accountEmail)) { |
|
46 | 46 | $this->markTestSkipped('Skipped: Account does already exist'); |
47 | 47 | } |
48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function testCreate() { |
56 | 56 | |
57 | - if(\LE_ACME2\Account::exists($this->_accountEmail)) { |
|
57 | + if (\LE_ACME2\Account::exists($this->_accountEmail)) { |
|
58 | 58 | // Skipping account modification tests, when the account already exists |
59 | 59 | // to reduce the LE api usage while developing |
60 | 60 | TestHelper::getInstance()->setSkipAccountModificationTests(true); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | public function testInvalidCreate() { |
78 | 78 | |
79 | - if(TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
79 | + if (TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
80 | 80 | $this->expectNotToPerformAssertions(); |
81 | 81 | return; |
82 | 82 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | public function testModification() { |
95 | 95 | |
96 | - if(TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
96 | + if (TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
97 | 97 | $this->expectNotToPerformAssertions(); |
98 | 98 | return; |
99 | 99 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | public function testDeactivation() { |
125 | 125 | |
126 | - if(TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
126 | + if (TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
127 | 127 | $this->expectNotToPerformAssertions(); |
128 | 128 | return; |
129 | 129 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | public function testCreationAfterDeactivation() { |
151 | 151 | |
152 | - if(TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
152 | + if (TestHelper::getInstance()->shouldSkipAccountModificationTests()) { |
|
153 | 153 | $this->expectNotToPerformAssertions(); |
154 | 154 | return; |
155 | 155 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @throws Exception\RateLimitReached |
36 | 36 | */ |
37 | 37 | protected function _existsNotValidChallenges(Response\Authorization\Struct\Challenge $challenge, |
38 | - Response\Authorization\Get $authorizationResponse |
|
38 | + Response\Authorization\Get $authorizationResponse |
|
39 | 39 | ) : bool { |
40 | 40 | |
41 | 41 | if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | Response\Authorization\Get $authorizationResponse |
39 | 39 | ) : bool { |
40 | 40 | |
41 | - if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
41 | + if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
42 | 42 | |
43 | - if(self::$_dnsWriter === null) { |
|
43 | + if (self::$_dnsWriter === null) { |
|
44 | 44 | throw new \RuntimeException('DNS writer is not set'); |
45 | 45 | } |
46 | 46 | |
47 | - if( self::$_dnsWriter->write( |
|
47 | + if (self::$_dnsWriter->write( |
|
48 | 48 | $this->_order, |
49 | 49 | $authorizationResponse->getIdentifier()->value, |
50 | 50 | (new ChallengeAuthorizationKey($this->_account))->getEncoded($challenge->token) |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
61 | + if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
62 | 62 | throw new Exception\DNSAuthorizationInvalid( |
63 | 63 | 'Received status "' . Response\Authorization\Struct\Challenge::STATUS_INVALID . '" while challenge should be verified' |
64 | 64 | ); |
@@ -130,7 +130,7 @@ |
||
130 | 130 | * @throws Exception\AuthorizationInvalid |
131 | 131 | */ |
132 | 132 | protected function _existsNotValidChallenges(Response\Authorization\Struct\Challenge $challenge, |
133 | - Response\Authorization\Get $authorizationResponse |
|
133 | + Response\Authorization\Get $authorizationResponse |
|
134 | 134 | ) : bool { |
135 | 135 | |
136 | 136 | if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function _fetchAuthorizationResponses() { |
46 | 46 | |
47 | - if(!file_exists($this->_order->getKeyDirectoryPath() . 'private.pem')) { |
|
47 | + if (!file_exists($this->_order->getKeyDirectoryPath() . 'private.pem')) { |
|
48 | 48 | |
49 | 49 | Utilities\Logger::getInstance()->add( |
50 | 50 | Utilities\Logger::LEVEL_DEBUG, |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $orderResponse = Cache\OrderResponse::getInstance()->get($this->_order); |
58 | 58 | |
59 | - foreach($orderResponse->getAuthorizations() as $authorization) { |
|
59 | + foreach ($orderResponse->getAuthorizations() as $authorization) { |
|
60 | 60 | |
61 | 61 | $this->_authorizationResponses[] = Cache\OrderAuthorizationResponse::getInstance() |
62 | 62 | ->get($this->_order, $authorization, $this->_getChallengeType()); |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | |
71 | 71 | public function shouldStartAuthorization() : bool { |
72 | 72 | |
73 | - foreach($this->_authorizationResponses as $response) { |
|
73 | + foreach ($this->_authorizationResponses as $response) { |
|
74 | 74 | |
75 | 75 | $challenge = $response->getChallenge($this->_getChallengeType()); |
76 | - if($challenge && $challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
76 | + if ($challenge && $challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
77 | 77 | |
78 | 78 | Utilities\Logger::getInstance()->add( |
79 | 79 | Utilities\Logger::LEVEL_DEBUG, |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function progress() { |
101 | 101 | |
102 | - if($this->_progressed) { |
|
102 | + if ($this->_progressed) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->_progressed = true; |
107 | 107 | |
108 | - if(!$this->_hasValidAuthorizationResponses()) |
|
108 | + if (!$this->_hasValidAuthorizationResponses()) |
|
109 | 109 | return; |
110 | 110 | |
111 | 111 | $existsNotValidChallenges = false; |
112 | 112 | |
113 | - foreach($this->_authorizationResponses as $authorizationResponse) { |
|
113 | + foreach ($this->_authorizationResponses as $authorizationResponse) { |
|
114 | 114 | |
115 | 115 | $challenge = $authorizationResponse->getChallenge($this->_getChallengeType()); |
116 | 116 | |
117 | - if($challenge && $this->_existsNotValidChallenges($challenge, $authorizationResponse)) { |
|
117 | + if ($challenge && $this->_existsNotValidChallenges($challenge, $authorizationResponse)) { |
|
118 | 118 | $existsNotValidChallenges = true; |
119 | 119 | } |
120 | 120 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | Response\Authorization\Get $authorizationResponse |
134 | 134 | ) : bool { |
135 | 135 | |
136 | - if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
136 | + if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
137 | 137 | |
138 | 138 | Utilities\Logger::getInstance()->add( |
139 | 139 | Utilities\Logger::LEVEL_DEBUG, |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | |
144 | 144 | return true; |
145 | 145 | } |
146 | - else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PROGRESSING) { |
|
146 | + else if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PROGRESSING) { |
|
147 | 147 | |
148 | 148 | // Should come back later |
149 | 149 | return true; |
150 | 150 | } |
151 | - else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_VALID) { |
|
151 | + else if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_VALID) { |
|
152 | 152 | |
153 | 153 | } |
154 | - else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
154 | + else if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
155 | 155 | throw new Exception\AuthorizationInvalid( |
156 | 156 | 'Received status "' . Response\Authorization\Struct\Challenge::STATUS_INVALID . '" while challenge should be verified' |
157 | 157 | ); |
@@ -105,8 +105,9 @@ discard block |
||
105 | 105 | |
106 | 106 | $this->_progressed = true; |
107 | 107 | |
108 | - if(!$this->_hasValidAuthorizationResponses()) |
|
109 | - return; |
|
108 | + if(!$this->_hasValidAuthorizationResponses()) { |
|
109 | + return; |
|
110 | + } |
|
110 | 111 | |
111 | 112 | $existsNotValidChallenges = false; |
112 | 113 | |
@@ -142,21 +143,17 @@ discard block |
||
142 | 143 | ); |
143 | 144 | |
144 | 145 | return true; |
145 | - } |
|
146 | - else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PROGRESSING) { |
|
146 | + } else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PROGRESSING) { |
|
147 | 147 | |
148 | 148 | // Should come back later |
149 | 149 | return true; |
150 | - } |
|
151 | - else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_VALID) { |
|
150 | + } else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_VALID) { |
|
152 | 151 | |
153 | - } |
|
154 | - else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
152 | + } else if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
155 | 153 | throw new Exception\AuthorizationInvalid( |
156 | 154 | 'Received status "' . Response\Authorization\Struct\Challenge::STATUS_INVALID . '" while challenge should be verified' |
157 | 155 | ); |
158 | - } |
|
159 | - else { |
|
156 | + } else { |
|
160 | 157 | |
161 | 158 | throw new \RuntimeException('Challenge status "' . $challenge->status . '" is not implemented'); |
162 | 159 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * @throws Exception\RateLimitReached |
51 | 51 | */ |
52 | 52 | protected function _existsNotValidChallenges(Response\Authorization\Struct\Challenge $challenge, |
53 | - Response\Authorization\Get $authorizationResponse |
|
53 | + Response\Authorization\Get $authorizationResponse |
|
54 | 54 | ) : bool { |
55 | 55 | |
56 | 56 | Utilities\Logger::getInstance()->add( |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | |
21 | 21 | public static function setDirectoryPath(string $directoryPath) { |
22 | 22 | |
23 | - if(!file_exists($directoryPath)) { |
|
23 | + if (!file_exists($directoryPath)) { |
|
24 | 24 | throw new \RuntimeException('HTTP authorization directory path does not exist'); |
25 | 25 | } |
26 | 26 | |
27 | 27 | self::$_directoryPath = realpath($directoryPath) . DIRECTORY_SEPARATOR; |
28 | 28 | |
29 | - if(!file_exists(self::$_directoryPath . 'test-token')) { |
|
29 | + if (!file_exists(self::$_directoryPath . 'test-token')) { |
|
30 | 30 | file_put_contents(self::$_directoryPath . self::TEST_TOKEN, self::TEST_CHALLENGE); |
31 | 31 | } |
32 | 32 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | 'Challenge "' . $challenge->token . '" has status:' . $challenge->status |
59 | 59 | ); |
60 | 60 | |
61 | - if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
61 | + if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_PENDING) { |
|
62 | 62 | |
63 | 63 | $this->_writeToFile($challenge); |
64 | - if($this->_validateFile($authorizationResponse->getIdentifier()->value, $challenge)) { |
|
64 | + if ($this->_validateFile($authorizationResponse->getIdentifier()->value, $challenge)) { |
|
65 | 65 | |
66 | 66 | $request = new Request\Authorization\Start($this->_account, $this->_order, $challenge); |
67 | 67 | /* $response = */ $request->getResponse(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
74 | + if ($challenge->status == Response\Authorization\Struct\Challenge::STATUS_INVALID) { |
|
75 | 75 | throw new Exception\HTTPAuthorizationInvalid( |
76 | 76 | 'Received status "' . Response\Authorization\Struct\Challenge::STATUS_INVALID . '" while challenge should be verified' |
77 | 77 | ); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $expectedResponse = $challengeAuthorizationKey->get($challenge->token); |
103 | 103 | $response = Utilities\ChallengeHTTP::fetch($domain, $challenge->token); |
104 | 104 | |
105 | - if($response != $expectedResponse) { |
|
105 | + if ($response != $expectedResponse) { |
|
106 | 106 | |
107 | 107 | throw new Exception\HTTPAuthorizationInvalid( |
108 | 108 | 'HTTP challenge for "' . $domain . '"": ' . |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | array_map(function($subject) { |
42 | 42 | |
43 | - if(preg_match_all('~(\*\.)~', $subject) > 1) |
|
43 | + if (preg_match_all('~(\*\.)~', $subject) > 1) |
|
44 | 44 | throw new \RuntimeException('Cannot create orders with multiple wildcards in one domain.'); |
45 | 45 | |
46 | 46 | }, $subjects); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | Utilities\Logger::getInstance()->add( |
81 | 81 | Utilities\Logger::LEVEL_INFO, |
82 | - get_class() . '::' . __FUNCTION__ . ' "' . implode(':', $subjects) . '"' |
|
82 | + get_class() . '::' . __FUNCTION__ . ' "' . implode(':', $subjects) . '"' |
|
83 | 83 | ); |
84 | 84 | |
85 | 85 | $order = new self($account, $subjects); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | Cache\OrderResponse::getInstance()->set($this, $response); |
105 | 105 | return $this; |
106 | 106 | |
107 | - } catch(Exception\AbstractException $e) { |
|
107 | + } catch (Exception\AbstractException $e) { |
|
108 | 108 | $this->_clearKeyDirectory(); |
109 | 109 | throw $e; |
110 | 110 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | |
121 | 121 | Utilities\Logger::getInstance()->add( |
122 | 122 | Utilities\Logger::LEVEL_INFO, |
123 | - get_class() . '::' . __FUNCTION__ . ' "' . implode(':', $subjects) . '"' |
|
123 | + get_class() . '::' . __FUNCTION__ . ' "' . implode(':', $subjects) . '"' |
|
124 | 124 | ); |
125 | 125 | |
126 | 126 | $order = new self($account, $subjects); |
127 | 127 | |
128 | - if(!self::exists($account, $subjects)) |
|
128 | + if (!self::exists($account, $subjects)) |
|
129 | 129 | throw new \RuntimeException('Order does not exist'); |
130 | 130 | |
131 | 131 | return $order; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function _getAuthorizer(string $type) : Authorizer\AbstractAuthorizer { |
145 | 145 | |
146 | - if($this->_authorizer === null) { |
|
146 | + if ($this->_authorizer === null) { |
|
147 | 147 | |
148 | - if($type == self::CHALLENGE_TYPE_HTTP) { |
|
148 | + if ($type == self::CHALLENGE_TYPE_HTTP) { |
|
149 | 149 | $this->_authorizer = new Authorizer\HTTP($this->_account, $this); |
150 | - } else if($type == self::CHALLENGE_TYPE_DNS) { |
|
150 | + } else if ($type == self::CHALLENGE_TYPE_DNS) { |
|
151 | 151 | $this->_authorizer = new Authorizer\DNS($this->_account, $this); |
152 | 152 | } else { |
153 | 153 | throw new \RuntimeException('Challenge type not implemented'); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | try { |
186 | 186 | return $this->_getAuthorizer($type)->shouldStartAuthorization(); |
187 | - } catch(Exception\ExpiredAuthorization $e) { |
|
187 | + } catch (Exception\ExpiredAuthorization $e) { |
|
188 | 188 | |
189 | 189 | $this->_clearAfterExpiredAuthorization(); |
190 | 190 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | return $authorizer->hasFinished(); |
209 | 209 | |
210 | - } catch(Exception\ExpiredAuthorization $e) { |
|
210 | + } catch (Exception\ExpiredAuthorization $e) { |
|
211 | 211 | |
212 | 212 | $this->_clearAfterExpiredAuthorization(); |
213 | 213 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function finalize() { |
224 | 224 | |
225 | - if(!is_object($this->_authorizer) || !$this->_authorizer->hasFinished()) { |
|
225 | + if (!is_object($this->_authorizer) || !$this->_authorizer->hasFinished()) { |
|
226 | 226 | |
227 | 227 | throw new \RuntimeException('Not all challenges are valid. Please check result of authorize() first!'); |
228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | $orderResponse = Cache\OrderResponse::getInstance()->get($this); |
236 | 236 | |
237 | - if( |
|
237 | + if ( |
|
238 | 238 | $orderResponse->getStatus() == Response\Order\AbstractOrder::STATUS_PENDING /* DEPRECATED AFTER JULI 5TH 2018 */ || |
239 | 239 | $orderResponse->getStatus() == Response\Order\AbstractOrder::STATUS_READY // ACME draft-12 Section 7.1.6 |
240 | 240 | ) { |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | Cache\OrderResponse::getInstance()->set($this, $orderResponse); |
246 | 246 | } |
247 | 247 | |
248 | - if($orderResponse->getStatus() == Response\Order\AbstractOrder::STATUS_VALID) { |
|
248 | + if ($orderResponse->getStatus() == Response\Order\AbstractOrder::STATUS_VALID) { |
|
249 | 249 | |
250 | 250 | $request = new Request\Order\GetCertificate($this, $orderResponse); |
251 | 251 | $response = $request->getResponse(); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | //$certificateValidToTimeTimestamp = $certificateInfo['validTo_time_t']; |
258 | 258 | $intermediateInfo = openssl_x509_parse($intermediate); |
259 | 259 | |
260 | - if(self::$_preferredChain !== null) { |
|
260 | + if (self::$_preferredChain !== null) { |
|
261 | 261 | Utilities\Logger::getInstance()->add( |
262 | 262 | Utilities\Logger::LEVEL_INFO, |
263 | 263 | 'Preferred chain is set: ' . self::$_preferredChain, |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | $found = false; |
268 | - if(self::$_preferredChain !== null && $intermediateInfo['issuer']['CN'] != self::$_preferredChain) { |
|
268 | + if (self::$_preferredChain !== null && $intermediateInfo['issuer']['CN'] != self::$_preferredChain) { |
|
269 | 269 | |
270 | 270 | Utilities\Logger::getInstance()->add( |
271 | 271 | Utilities\Logger::LEVEL_INFO, |
272 | 272 | 'Default certificate does not satisfy preferred chain, trying to fetch alternative' |
273 | 273 | ); |
274 | 274 | |
275 | - foreach($response->getAlternativeLinks() as $link) { |
|
275 | + foreach ($response->getAlternativeLinks() as $link) { |
|
276 | 276 | |
277 | 277 | $request = new Request\Order\GetCertificate($this, $orderResponse, $link); |
278 | 278 | $response = $request->getResponse(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $alternativeIntermediate = $response->getIntermediate(); |
282 | 282 | |
283 | 283 | $intermediateInfo = openssl_x509_parse($intermediate); |
284 | - if($intermediateInfo['issuer']['CN'] != self::$_preferredChain) { |
|
284 | + if ($intermediateInfo['issuer']['CN'] != self::$_preferredChain) { |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | break; |
294 | 294 | } |
295 | 295 | |
296 | - if(!$found) { |
|
296 | + if (!$found) { |
|
297 | 297 | Utilities\Logger::getInstance()->add( |
298 | 298 | Utilities\Logger::LEVEL_INFO, |
299 | 299 | 'Preferred chain could not be satisfied, returning default chain' |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | protected function _getLatestCertificateDirectory() : ?string { |
326 | 326 | |
327 | 327 | $files = scandir($this->getKeyDirectoryPath(), SORT_NUMERIC | SORT_DESC); |
328 | - foreach($files as $file) { |
|
329 | - if( |
|
328 | + foreach ($files as $file) { |
|
329 | + if ( |
|
330 | 330 | substr($file, 0, strlen(self::BUNDLE_DIRECTORY_PREFIX)) == self::BUNDLE_DIRECTORY_PREFIX && |
331 | 331 | is_dir($this->getKeyDirectoryPath() . $file) |
332 | 332 | ) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | public function getCertificateBundle() : Struct\CertificateBundle { |
345 | 345 | |
346 | - if(!$this->isCertificateBundleAvailable()) { |
|
346 | + if (!$this->isCertificateBundleAvailable()) { |
|
347 | 347 | throw new \RuntimeException('There is no certificate available'); |
348 | 348 | } |
349 | 349 | |
@@ -365,35 +365,35 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function enableAutoRenewal($keyType = self::KEY_TYPE_RSA, int $renewBefore = null) { |
367 | 367 | |
368 | - if($keyType === null) { |
|
368 | + if ($keyType === null) { |
|
369 | 369 | $keyType = self::KEY_TYPE_RSA; |
370 | 370 | } |
371 | 371 | |
372 | - if(!$this->isCertificateBundleAvailable()) { |
|
372 | + if (!$this->isCertificateBundleAvailable()) { |
|
373 | 373 | throw new \RuntimeException('There is no certificate available'); |
374 | 374 | } |
375 | 375 | |
376 | 376 | $orderResponse = Cache\OrderResponse::getInstance()->get($this); |
377 | - if( |
|
377 | + if ( |
|
378 | 378 | $orderResponse === null || |
379 | 379 | $orderResponse->getStatus() != Response\Order\AbstractOrder::STATUS_VALID |
380 | 380 | ) { |
381 | 381 | return; |
382 | 382 | } |
383 | 383 | |
384 | - Utilities\Logger::getInstance()->add(Utilities\Logger::LEVEL_DEBUG,'Auto renewal triggered'); |
|
384 | + Utilities\Logger::getInstance()->add(Utilities\Logger::LEVEL_DEBUG, 'Auto renewal triggered'); |
|
385 | 385 | |
386 | 386 | $directory = $this->_getLatestCertificateDirectory(); |
387 | 387 | |
388 | 388 | $expireTime = self::_getExpireTimeFromCertificateDirectoryPath($directory); |
389 | 389 | |
390 | - if($renewBefore === null) { |
|
390 | + if ($renewBefore === null) { |
|
391 | 391 | $renewBefore = strtotime('-30 days', $expireTime); |
392 | 392 | } |
393 | 393 | |
394 | - if($renewBefore < time()) { |
|
394 | + if ($renewBefore < time()) { |
|
395 | 395 | |
396 | - Utilities\Logger::getInstance()->add(Utilities\Logger::LEVEL_INFO,'Auto renewal: Will recreate order'); |
|
396 | + Utilities\Logger::getInstance()->add(Utilities\Logger::LEVEL_INFO, 'Auto renewal: Will recreate order'); |
|
397 | 397 | |
398 | 398 | $this->_create($keyType, true); |
399 | 399 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | */ |
408 | 408 | public function revokeCertificate(int $reason = 0) : bool { |
409 | 409 | |
410 | - if(!$this->isCertificateBundleAvailable()) { |
|
410 | + if (!$this->isCertificateBundleAvailable()) { |
|
411 | 411 | throw new \RuntimeException('There is no certificate available to revoke'); |
412 | 412 | } |
413 | 413 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $this->_getKeyDirectoryPath('-revoked-' . microtime(true)) |
423 | 423 | ); |
424 | 424 | return true; |
425 | - } catch(Exception\InvalidResponse $e) { |
|
425 | + } catch (Exception\InvalidResponse $e) { |
|
426 | 426 | return false; |
427 | 427 | } |
428 | 428 | } |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | protected static function _getExpireTimeFromCertificateDirectoryPath(string $path) { |
431 | 431 | |
432 | 432 | $stringPosition = strrpos($path, self::BUNDLE_DIRECTORY_PREFIX); |
433 | - if($stringPosition === false) { |
|
433 | + if ($stringPosition === false) { |
|
434 | 434 | throw new \RuntimeException('ExpireTime not found in' . $path); |
435 | 435 | } |
436 | 436 | |
437 | 437 | $expireTime = substr($path, $stringPosition + strlen(self::BUNDLE_DIRECTORY_PREFIX)); |
438 | - if( |
|
438 | + if ( |
|
439 | 439 | !is_numeric($expireTime) || |
440 | 440 | $expireTime < strtotime('-10 years') || |
441 | 441 | $expireTime > strtotime('+10 years') |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | |
41 | 41 | array_map(function($subject) { |
42 | 42 | |
43 | - if(preg_match_all('~(\*\.)~', $subject) > 1) |
|
44 | - throw new \RuntimeException('Cannot create orders with multiple wildcards in one domain.'); |
|
43 | + if(preg_match_all('~(\*\.)~', $subject) > 1) { |
|
44 | + throw new \RuntimeException('Cannot create orders with multiple wildcards in one domain.'); |
|
45 | + } |
|
45 | 46 | |
46 | 47 | }, $subjects); |
47 | 48 | |
@@ -125,8 +126,9 @@ discard block |
||
125 | 126 | |
126 | 127 | $order = new self($account, $subjects); |
127 | 128 | |
128 | - if(!self::exists($account, $subjects)) |
|
129 | - throw new \RuntimeException('Order does not exist'); |
|
129 | + if(!self::exists($account, $subjects)) { |
|
130 | + throw new \RuntimeException('Order does not exist'); |
|
131 | + } |
|
130 | 132 | |
131 | 133 | return $order; |
132 | 134 | } |
@@ -51,11 +51,11 @@ |
||
51 | 51 | */ |
52 | 52 | protected function _isValid(): bool { |
53 | 53 | |
54 | - if(!parent::_isValid()) { |
|
54 | + if (!parent::_isValid()) { |
|
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | - if( |
|
58 | + if ( |
|
59 | 59 | $this->getStatus() == AbstractOrder::STATUS_INVALID |
60 | 60 | ) { |
61 | 61 | throw new Exception\OrderStatusInvalid( |