@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function get() : Response\GetNewNonce { |
25 | 25 | |
26 | - if(array_key_exists($this->_index, $this->_responses)) { |
|
26 | + if (array_key_exists($this->_index, $this->_responses)) { |
|
27 | 27 | return $this->_responses[$this->_index]; |
28 | 28 | } |
29 | 29 | $this->_responses[$this->_index] = null; |
@@ -34,23 +34,23 @@ discard block |
||
34 | 34 | $accountIdentifier = $this->_getObjectIdentifier($order->getAccount()); |
35 | 35 | $orderIdentifier = $this->_getObjectIdentifier($order); |
36 | 36 | |
37 | - if(!isset($this->_responses[$accountIdentifier][$orderIdentifier])) { |
|
37 | + if (!isset($this->_responses[$accountIdentifier][$orderIdentifier])) { |
|
38 | 38 | $this->_responses[$accountIdentifier][$orderIdentifier] = []; |
39 | 39 | } |
40 | 40 | |
41 | - if(array_key_exists($authorizationUrl, $this->_responses[$accountIdentifier][$orderIdentifier])) { |
|
42 | - return $this->_responses[ $accountIdentifier ][ $orderIdentifier ][ $authorizationUrl ]; |
|
41 | + if (array_key_exists($authorizationUrl, $this->_responses[$accountIdentifier][$orderIdentifier])) { |
|
42 | + return $this->_responses[$accountIdentifier][$orderIdentifier][$authorizationUrl]; |
|
43 | 43 | } |
44 | - $this->_responses[ $accountIdentifier ][ $orderIdentifier ][ $authorizationUrl ] = null; |
|
44 | + $this->_responses[$accountIdentifier][$orderIdentifier][$authorizationUrl] = null; |
|
45 | 45 | |
46 | 46 | $cacheFile = $this->_getCacheFilePath($order, $authorizationUrl); |
47 | 47 | |
48 | - if(file_exists($cacheFile)) { |
|
48 | + if (file_exists($cacheFile)) { |
|
49 | 49 | |
50 | 50 | $rawResponse = Connector\RawResponse::getFromString(file_get_contents($cacheFile)); |
51 | 51 | |
52 | 52 | $response = new Response\Authorization\Get($rawResponse); |
53 | - if( |
|
53 | + if ( |
|
54 | 54 | ($challenge = $response->getChallenge($challengeType)) && |
55 | 55 | $challenge->status == Response\Authorization\Struct\Challenge::STATUS_PROGRESSING |
56 | 56 | ) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | Utilities\Logger::getInstance()->add( |
69 | 69 | Utilities\Logger::LEVEL_DEBUG, |
70 | - get_class() . '::' . __FUNCTION__ . ' (from cache, status "' . $response->getStatus() . '")' |
|
70 | + get_class() . '::' . __FUNCTION__ . ' (from cache, status "' . $response->getStatus() . '")' |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | $this->_responses[$accountIdentifier][$orderIdentifier][$authorizationUrl] = $response; |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | |
88 | 88 | $filePath = $this->_getCacheFilePath($order, $authorizationUrl); |
89 | 89 | |
90 | - if($response === null) { |
|
90 | + if ($response === null) { |
|
91 | 91 | |
92 | 92 | unset($this->_responses[$accountIdentifier][$orderIdentifier][$authorizationUrl]); |
93 | 93 | |
94 | - if(file_exists($filePath)) { |
|
94 | + if (file_exists($filePath)) { |
|
95 | 95 | unlink($filePath); |
96 | 96 | } |
97 | 97 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function clear(Order $order) : void { |
116 | 116 | |
117 | 117 | $orderResponse = OrderResponse::getInstance()->get($order); |
118 | - foreach($orderResponse->getAuthorizations() as $authorization) { |
|
118 | + foreach ($orderResponse->getAuthorizations() as $authorization) { |
|
119 | 119 | $this->set($order, $authorization, null); |
120 | 120 | } |
121 | 121 | } |
@@ -37,29 +37,29 @@ discard block |
||
37 | 37 | $accountIdentifier = $this->_getObjectIdentifier($order->getAccount()); |
38 | 38 | $orderIdentifier = $this->_getObjectIdentifier($order); |
39 | 39 | |
40 | - if(!isset($this->_responses[$accountIdentifier])) { |
|
40 | + if (!isset($this->_responses[$accountIdentifier])) { |
|
41 | 41 | $this->_responses[$accountIdentifier] = []; |
42 | 42 | } |
43 | 43 | |
44 | - if(array_key_exists($orderIdentifier, $this->_responses[$accountIdentifier])) { |
|
45 | - return $this->_responses[ $accountIdentifier ][ $orderIdentifier ]; |
|
44 | + if (array_key_exists($orderIdentifier, $this->_responses[$accountIdentifier])) { |
|
45 | + return $this->_responses[$accountIdentifier][$orderIdentifier]; |
|
46 | 46 | } |
47 | - $this->_responses[ $accountIdentifier ][ $orderIdentifier ] = null; |
|
47 | + $this->_responses[$accountIdentifier][$orderIdentifier] = null; |
|
48 | 48 | |
49 | 49 | $cacheFile = $order->getKeyDirectoryPath() . self::_FILE; |
50 | 50 | $deprecatedCacheFile = $order->getKeyDirectoryPath() . self::_DEPRECATED_FILE; |
51 | 51 | |
52 | - if(file_exists($deprecatedCacheFile) && !file_exists($cacheFile)) { |
|
52 | + if (file_exists($deprecatedCacheFile) && !file_exists($cacheFile)) { |
|
53 | 53 | rename($deprecatedCacheFile, $cacheFile); |
54 | 54 | } |
55 | 55 | |
56 | - if(file_exists($cacheFile)) { |
|
56 | + if (file_exists($cacheFile)) { |
|
57 | 57 | |
58 | 58 | $rawResponse = Connector\RawResponse::getFromString(file_get_contents($cacheFile)); |
59 | 59 | |
60 | 60 | $response = new Response\Order\Create($rawResponse); |
61 | 61 | |
62 | - if( |
|
62 | + if ( |
|
63 | 63 | $response->getStatus() != Response\Order\AbstractOrder::STATUS_VALID |
64 | 64 | ) { |
65 | 65 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | Utilities\Logger::getInstance()->add( |
78 | 78 | Utilities\Logger::LEVEL_DEBUG, |
79 | - get_class() . '::' . __FUNCTION__ . ' (from cache, status "' . $response->getStatus() . '")' |
|
79 | + get_class() . '::' . __FUNCTION__ . ' (from cache, status "' . $response->getStatus() . '")' |
|
80 | 80 | ); |
81 | 81 | |
82 | 82 | $this->_responses[$accountIdentifier][$orderIdentifier] = $response; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | |
99 | 99 | $filePath = $order->getKeyDirectoryPath() . self::_FILE; |
100 | 100 | |
101 | - if($response === null) { |
|
101 | + if ($response === null) { |
|
102 | 102 | |
103 | 103 | unset($this->_responses[$accountIdentifier][$orderIdentifier]); |
104 | 104 | |
105 | - if(file_exists($filePath)) { |
|
105 | + if (file_exists($filePath)) { |
|
106 | 106 | unlink($filePath); |
107 | 107 | } |
108 | 108 |
@@ -28,25 +28,25 @@ discard block |
||
28 | 28 | |
29 | 29 | $accountIdentifier = $this->_getObjectIdentifier($account); |
30 | 30 | |
31 | - if(array_key_exists($accountIdentifier, $this->_responses)) { |
|
32 | - return $this->_responses[ $accountIdentifier ]; |
|
31 | + if (array_key_exists($accountIdentifier, $this->_responses)) { |
|
32 | + return $this->_responses[$accountIdentifier]; |
|
33 | 33 | } |
34 | - $this->_responses[ $accountIdentifier ] = null; |
|
34 | + $this->_responses[$accountIdentifier] = null; |
|
35 | 35 | |
36 | 36 | $cacheFile = $account->getKeyDirectoryPath() . self::_FILE; |
37 | 37 | $deprecatedCacheFile = $account->getKeyDirectoryPath() . self::_DEPRECATED_FILE; |
38 | 38 | |
39 | - if(file_exists($deprecatedCacheFile) && !file_exists($cacheFile)) { |
|
39 | + if (file_exists($deprecatedCacheFile) && !file_exists($cacheFile)) { |
|
40 | 40 | rename($deprecatedCacheFile, $cacheFile); |
41 | 41 | } |
42 | 42 | |
43 | - if(file_exists($cacheFile) && filemtime($cacheFile) > strtotime('-7 days')) { |
|
43 | + if (file_exists($cacheFile) && filemtime($cacheFile) > strtotime('-7 days')) { |
|
44 | 44 | |
45 | 45 | $rawResponse = Connector\RawResponse::getFromString(file_get_contents($cacheFile)); |
46 | 46 | |
47 | 47 | $response = new Response\Account\Create($rawResponse); |
48 | 48 | |
49 | - $this->_responses[ $accountIdentifier ] = $response; |
|
49 | + $this->_responses[$accountIdentifier] = $response; |
|
50 | 50 | |
51 | 51 | Utilities\Logger::getInstance()->add( |
52 | 52 | Utilities\Logger::LEVEL_DEBUG, |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | $filePath = $account->getKeyDirectoryPath() . self::_FILE; |
72 | 72 | |
73 | - if($response === null) { |
|
73 | + if ($response === null) { |
|
74 | 74 | |
75 | 75 | unset($this->_responses[$accountIdentifier]); |
76 | 76 | |
77 | - if(file_exists($filePath)) { |
|
77 | + if (file_exists($filePath)) { |
|
78 | 78 | unlink($filePath); |
79 | 79 | } |
80 | 80 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | final public static function getInstance(): self { |
12 | 12 | |
13 | - if( self::$_instance === NULL ) { |
|
13 | + if (self::$_instance === NULL) { |
|
14 | 14 | self::$_instance = new self(); |
15 | 15 | } |
16 | 16 | return self::$_instance; |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | $account_email = '[email protected]'; |
38 | 38 | |
39 | 39 | $account = !\LE_ACME2\Account::exists($account_email) ? |
40 | - \LE_ACME2\Account::create($account_email) : |
|
41 | - \LE_ACME2\Account::get($account_email); |
|
40 | + \LE_ACME2\Account::create($account_email) : \LE_ACME2\Account::get($account_email); |
|
42 | 41 | |
43 | 42 | // Update email address |
44 | 43 | // $account->update('[email protected]'); |
@@ -52,7 +51,7 @@ discard block |
||
52 | 51 | 'www.example.org' |
53 | 52 | ]; |
54 | 53 | |
55 | -if(!\LE_ACME2\Order::exists($account, $subjects)) { |
|
54 | +if (!\LE_ACME2\Order::exists($account, $subjects)) { |
|
56 | 55 | |
57 | 56 | // Do some pre-checks, f.e. external dns checks - not required |
58 | 57 | |
@@ -65,15 +64,15 @@ discard block |
||
65 | 64 | // Already received certificate bundles will not be affected |
66 | 65 | // $order->clear(); |
67 | 66 | |
68 | -if($order->shouldStartAuthorization(\LE_ACME2\Order::CHALLENGE_TYPE_DNS)) { |
|
67 | +if ($order->shouldStartAuthorization(\LE_ACME2\Order::CHALLENGE_TYPE_DNS)) { |
|
69 | 68 | // Do some pre-checks, f.e. external dns checks - not required |
70 | 69 | } |
71 | 70 | |
72 | -if($order->authorize(\LE_ACME2\Order::CHALLENGE_TYPE_DNS)) { |
|
71 | +if ($order->authorize(\LE_ACME2\Order::CHALLENGE_TYPE_DNS)) { |
|
73 | 72 | $order->finalize(); |
74 | 73 | } |
75 | 74 | |
76 | -if($order->isCertificateBundleAvailable()) { |
|
75 | +if ($order->isCertificateBundleAvailable()) { |
|
77 | 76 | |
78 | 77 | $bundle = $order->getCertificateBundle(); |
79 | 78 | $order->enableAutoRenewal(); |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | $account_email = '[email protected]'; |
25 | 25 | |
26 | 26 | $account = !\LE_ACME2\Account::exists($account_email) ? |
27 | - \LE_ACME2\Account::create($account_email) : |
|
28 | - \LE_ACME2\Account::get($account_email); |
|
27 | + \LE_ACME2\Account::create($account_email) : \LE_ACME2\Account::get($account_email); |
|
29 | 28 | |
30 | 29 | // Update email address |
31 | 30 | // $account->update('[email protected]'); |
@@ -39,7 +38,7 @@ discard block |
||
39 | 38 | 'www.example.org' |
40 | 39 | ]; |
41 | 40 | |
42 | -if(!\LE_ACME2\Order::exists($account, $subjects)) { |
|
41 | +if (!\LE_ACME2\Order::exists($account, $subjects)) { |
|
43 | 42 | |
44 | 43 | // Do some pre-checks, f.e. external dns checks - not required |
45 | 44 | |
@@ -52,31 +51,31 @@ discard block |
||
52 | 51 | // Already received certificate bundles will not be affected |
53 | 52 | // $order->clear(); |
54 | 53 | |
55 | -if($order->shouldStartAuthorization(\LE_ACME2\Order::CHALLENGE_TYPE_HTTP)) { |
|
54 | +if ($order->shouldStartAuthorization(\LE_ACME2\Order::CHALLENGE_TYPE_HTTP)) { |
|
56 | 55 | // Do some pre-checks, f.e. external dns checks - not required |
57 | 56 | |
58 | 57 | // Example test: |
59 | - foreach($subjects as $subject) { |
|
58 | + foreach ($subjects as $subject) { |
|
60 | 59 | try { |
61 | 60 | $response = \LE_ACME2\Utilities\ChallengeHTTP::fetch($subject, \LE_ACME2\Authorizer\HTTP::TEST_TOKEN); |
62 | - if($response != \LE_ACME2\Authorizer\HTTP::TEST_CHALLENGE) { |
|
61 | + if ($response != \LE_ACME2\Authorizer\HTTP::TEST_CHALLENGE) { |
|
63 | 62 | die('Invalid response: ' . var_export([ |
64 | 63 | 'Expected:' => \LE_ACME2\Authorizer\HTTP::TEST_CHALLENGE, |
65 | 64 | 'Response:' => $response, |
66 | 65 | ])); |
67 | 66 | } |
68 | - } catch(\LE_ACME2\Exception\HTTPAuthorizationInvalid $e) { |
|
67 | + } catch (\LE_ACME2\Exception\HTTPAuthorizationInvalid $e) { |
|
69 | 68 | die('Exception thrown while validating HTTP authorization: ' . $e->getMessage()); |
70 | 69 | } |
71 | 70 | } |
72 | 71 | |
73 | 72 | } |
74 | 73 | |
75 | -if($order->authorize(\LE_ACME2\Order::CHALLENGE_TYPE_HTTP)) { |
|
74 | +if ($order->authorize(\LE_ACME2\Order::CHALLENGE_TYPE_HTTP)) { |
|
76 | 75 | $order->finalize(); |
77 | 76 | } |
78 | 77 | |
79 | -if($order->isCertificateBundleAvailable()) { |
|
78 | +if ($order->isCertificateBundleAvailable()) { |
|
80 | 79 | |
81 | 80 | $bundle = $order->getCertificateBundle(); |
82 | 81 | $order->enableAutoRenewal(); |