@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | else throw LEOrderException::InvalidKeyTypeException($keyType); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if(preg_match('~(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|^$)~', $notBefore) == false OR preg_match('~(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|^$)~', $notAfter) == false) |
|
| 104 | + if (preg_match('~(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|^$)~', $notBefore) == false OR preg_match('~(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|^$)~', $notAfter) == false) |
|
| 105 | 105 | { |
| 106 | 106 | throw LEOrderException::InvalidArgumentException('notBefore and notAfter fields must be empty or be a string similar to 0000-00-00T00:00:00Z'); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $this->certificateKeys = $certificateKeys; |
| 110 | 110 | |
| 111 | - if(file_exists($this->certificateKeys['private_key']) AND file_exists($this->certificateKeys['order']) AND file_exists($this->certificateKeys['public_key'])) |
|
| 111 | + if (file_exists($this->certificateKeys['private_key']) AND file_exists($this->certificateKeys['order']) AND file_exists($this->certificateKeys['public_key'])) |
|
| 112 | 112 | { |
| 113 | 113 | $this->orderURL = file_get_contents($this->certificateKeys['order']); |
| 114 | 114 | if (filter_var($this->orderURL, FILTER_VALIDATE_URL) !== false) |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->orderURL); |
| 119 | 119 | $post = $this->connector->post($this->orderURL, $sign); |
| 120 | - if($post['body']['status'] == "invalid") |
|
| 120 | + if ($post['body']['status'] == "invalid") |
|
| 121 | 121 | { |
| 122 | 122 | throw LEOrderException::InvalidOrderStatusException(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $orderdomains = array_map(function($ident) { return $ident['value']; }, $post['body']['identifiers']); |
| 126 | 126 | $diff = array_merge(array_diff($orderdomains, $domains), array_diff($domains, $orderdomains)); |
| 127 | - if(!empty($diff)) |
|
| 127 | + if (!empty($diff)) |
|
| 128 | 128 | { |
| 129 | 129 | foreach ($this->certificateKeys as $file) |
| 130 | 130 | { |
| 131 | - if (is_file($file)) rename($file, $file.'.old'); |
|
| 131 | + if (is_file($file)) rename($file, $file . '.old'); |
|
| 132 | 132 | } |
| 133 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 133 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 134 | 134 | { |
| 135 | 135 | $this->log->info('Domains do not match order data. Renaming current files and creating new order.'); |
| 136 | 136 | } |
| 137 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Domains do not match order data. Renaming current files and creating new order.', 'function LEOrder __construct'); |
|
| 137 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Domains do not match order data. Renaming current files and creating new order.', 'function LEOrder __construct'); |
|
| 138 | 138 | $this->createOrder($domains, $notBefore, $notAfter, $keyType); |
| 139 | 139 | } |
| 140 | 140 | else |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->identifiers = $post['body']['identifiers']; |
| 145 | 145 | $this->authorizationURLs = $post['body']['authorizations']; |
| 146 | 146 | $this->finalizeURL = $post['body']['finalize']; |
| 147 | - if(array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 147 | + if (array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 148 | 148 | $this->updateAuthorizations(); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | if (is_file($file)) unlink($file); |
| 156 | 156 | } |
| 157 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 157 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 158 | 158 | { |
| 159 | 159 | $this->log->info('Order data for \'' . $this->basename . '\' invalid. Deleting order data and creating new order.'); |
| 160 | 160 | } |
| 161 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order data for \'' . $this->basename . '\' invalid. Deleting order data and creating new order.', 'function LEOrder __construct'); |
|
| 161 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order data for \'' . $this->basename . '\' invalid. Deleting order data and creating new order.', 'function LEOrder __construct'); |
|
| 162 | 162 | $this->createOrder($domains, $notBefore, $notAfter); |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -169,22 +169,22 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | if (is_file($file)) unlink($file); |
| 171 | 171 | } |
| 172 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 172 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 173 | 173 | { |
| 174 | 174 | $this->log->info('Order data for \'' . $this->basename . '\' invalid. Deleting order data and creating new order.'); |
| 175 | 175 | } |
| 176 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order data for \'' . $this->basename . '\' invalid. Deleting order data and creating new order.', 'function LEOrder __construct'); |
|
| 176 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order data for \'' . $this->basename . '\' invalid. Deleting order data and creating new order.', 'function LEOrder __construct'); |
|
| 177 | 177 | |
| 178 | 178 | $this->createOrder($domains, $notBefore, $notAfter); |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | else |
| 182 | 182 | { |
| 183 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 183 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 184 | 184 | { |
| 185 | 185 | $this->log->info('No order found for \'' . $this->basename . '\'. Creating new order.'); |
| 186 | 186 | } |
| 187 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('No order found for \'' . $this->basename . '\'. Creating new order.', 'function LEOrder __construct'); |
|
| 187 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('No order found for \'' . $this->basename . '\'. Creating new order.', 'function LEOrder __construct'); |
|
| 188 | 188 | $this->createOrder($domains, $notBefore, $notAfter); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | private function createOrder($domains, $notBefore, $notAfter) |
| 200 | 200 | { |
| 201 | 201 | $dns = array(); |
| 202 | - foreach($domains as $domain) |
|
| 202 | + foreach ($domains as $domain) |
|
| 203 | 203 | { |
| 204 | - if(preg_match_all('~(\*\.)~', $domain) > 1) throw LEOrderException::InvalidArgumentException('Cannot create orders with multiple wildcards in one domain.'); |
|
| 204 | + if (preg_match_all('~(\*\.)~', $domain) > 1) throw LEOrderException::InvalidArgumentException('Cannot create orders with multiple wildcards in one domain.'); |
|
| 205 | 205 | $dns[] = array('type' => 'dns', 'value' => $domain); |
| 206 | 206 | } |
| 207 | 207 | $payload = array("identifiers" => $dns, 'notBefore' => $notBefore, 'notAfter' => $notAfter); |
| 208 | 208 | $sign = $this->connector->signRequestKid($payload, $this->connector->accountURL, $this->connector->newOrder); |
| 209 | 209 | $post = $this->connector->post($this->connector->newOrder, $sign); |
| 210 | 210 | |
| 211 | - if($post['status'] === 201) |
|
| 211 | + if ($post['status'] === 201) |
|
| 212 | 212 | { |
| 213 | - if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) |
|
| 213 | + if (preg_match('~Location: (\S+)~i', $post['header'], $matches)) |
|
| 214 | 214 | { |
| 215 | 215 | $this->orderURL = trim($matches[1]); |
| 216 | 216 | file_put_contents($this->certificateKeys['order'], $this->orderURL); |
@@ -232,14 +232,14 @@ discard block |
||
| 232 | 232 | $this->identifiers = $post['body']['identifiers']; |
| 233 | 233 | $this->authorizationURLs = $post['body']['authorizations']; |
| 234 | 234 | $this->finalizeURL = $post['body']['finalize']; |
| 235 | - if(array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 235 | + if (array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 236 | 236 | $this->updateAuthorizations(); |
| 237 | 237 | |
| 238 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 238 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 239 | 239 | { |
| 240 | 240 | $this->log->info('Created order for \'' . $this->basename . '\'.'); |
| 241 | 241 | } |
| 242 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Created order for \'' . $this->basename . '\'.', 'function createOrder (function LEOrder __construct)'); |
|
| 242 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Created order for \'' . $this->basename . '\'.', 'function createOrder (function LEOrder __construct)'); |
|
| 243 | 243 | } |
| 244 | 244 | else |
| 245 | 245 | { |
@@ -259,23 +259,23 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | $sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->orderURL); |
| 261 | 261 | $post = $this->connector->post($this->orderURL, $sign); |
| 262 | - if($post['status'] === 200) |
|
| 262 | + if ($post['status'] === 200) |
|
| 263 | 263 | { |
| 264 | 264 | $this->status = $post['body']['status']; |
| 265 | 265 | $this->expires = $post['body']['expires']; |
| 266 | 266 | $this->identifiers = $post['body']['identifiers']; |
| 267 | 267 | $this->authorizationURLs = $post['body']['authorizations']; |
| 268 | 268 | $this->finalizeURL = $post['body']['finalize']; |
| 269 | - if(array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 269 | + if (array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 270 | 270 | $this->updateAuthorizations(); |
| 271 | 271 | } |
| 272 | 272 | else |
| 273 | 273 | { |
| 274 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 274 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 275 | 275 | { |
| 276 | 276 | $this->log->info('Cannot update data for order \'' . $this->basename . '\'.'); |
| 277 | 277 | } |
| 278 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot update data for order \'' . $this->basename . '\'.', 'function updateOrderData'); |
|
| 278 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot update data for order \'' . $this->basename . '\'.', 'function updateOrderData'); |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
@@ -285,12 +285,12 @@ discard block |
||
| 285 | 285 | private function updateAuthorizations() |
| 286 | 286 | { |
| 287 | 287 | $this->authorizations = array(); |
| 288 | - foreach($this->authorizationURLs as $authURL) |
|
| 288 | + foreach ($this->authorizationURLs as $authURL) |
|
| 289 | 289 | { |
| 290 | 290 | if (filter_var($authURL, FILTER_VALIDATE_URL)) |
| 291 | 291 | { |
| 292 | 292 | $auth = new LEAuthorization($this->connector, $this->log, $authURL); |
| 293 | - if($auth != false) $this->authorizations[] = $auth; |
|
| 293 | + if ($auth != false) $this->authorizations[] = $auth; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function allAuthorizationsValid() |
| 304 | 304 | { |
| 305 | - if(count($this->authorizations) > 0) |
|
| 305 | + if (count($this->authorizations) > 0) |
|
| 306 | 306 | { |
| 307 | - foreach($this->authorizations as $auth) |
|
| 307 | + foreach ($this->authorizations as $auth) |
|
| 308 | 308 | { |
| 309 | - if($auth->status != 'valid') return false; |
|
| 309 | + if ($auth->status != 'valid') return false; |
|
| 310 | 310 | } |
| 311 | 311 | return true; |
| 312 | 312 | } |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | ); |
| 340 | 340 | $digest = LEFunctions::Base64UrlSafeEncode(hash('sha256', json_encode($header), true)); |
| 341 | 341 | |
| 342 | - foreach($this->authorizations as $auth) |
|
| 342 | + foreach ($this->authorizations as $auth) |
|
| 343 | 343 | { |
| 344 | - if($auth->status == 'pending') |
|
| 344 | + if ($auth->status == 'pending') |
|
| 345 | 345 | { |
| 346 | 346 | $challenge = $auth->getChallenge($type); |
| 347 | - if($challenge['status'] == 'pending') |
|
| 347 | + if ($challenge['status'] == 'pending') |
|
| 348 | 348 | { |
| 349 | 349 | $keyAuthorization = $challenge['token'] . '.' . $digest; |
| 350 | - switch(strtolower($type)) |
|
| 350 | + switch (strtolower($type)) |
|
| 351 | 351 | { |
| 352 | 352 | case LEOrder::CHALLENGE_TYPE_HTTP: |
| 353 | 353 | $authorizations[] = array('type' => LEOrder::CHALLENGE_TYPE_HTTP, 'identifier' => $auth->identifier['value'], 'filename' => $challenge['token'], 'content' => $keyAuthorization); |
@@ -387,34 +387,34 @@ discard block |
||
| 387 | 387 | ); |
| 388 | 388 | $digest = LEFunctions::Base64UrlSafeEncode(hash('sha256', json_encode($header), true)); |
| 389 | 389 | |
| 390 | - foreach($this->authorizations as $auth) |
|
| 390 | + foreach ($this->authorizations as $auth) |
|
| 391 | 391 | { |
| 392 | - if($auth->identifier['value'] == $identifier) |
|
| 392 | + if ($auth->identifier['value'] == $identifier) |
|
| 393 | 393 | { |
| 394 | - if($auth->status == 'pending') |
|
| 394 | + if ($auth->status == 'pending') |
|
| 395 | 395 | { |
| 396 | 396 | $challenge = $auth->getChallenge($type); |
| 397 | - if($challenge['status'] == 'pending') |
|
| 397 | + if ($challenge['status'] == 'pending') |
|
| 398 | 398 | { |
| 399 | 399 | $keyAuthorization = $challenge['token'] . '.' . $digest; |
| 400 | - switch($type) |
|
| 400 | + switch ($type) |
|
| 401 | 401 | { |
| 402 | 402 | case LEOrder::CHALLENGE_TYPE_HTTP: |
| 403 | - if($localcheck == false OR LEFunctions::checkHTTPChallenge($identifier, $challenge['token'], $keyAuthorization)) |
|
| 403 | + if ($localcheck == false OR LEFunctions::checkHTTPChallenge($identifier, $challenge['token'], $keyAuthorization)) |
|
| 404 | 404 | { |
| 405 | 405 | $sign = $this->connector->signRequestKid(array('keyAuthorization' => $keyAuthorization), $this->connector->accountURL, $challenge['url']); |
| 406 | 406 | $post = $this->connector->post($challenge['url'], $sign); |
| 407 | - if($post['status'] === 200) |
|
| 407 | + if ($post['status'] === 200) |
|
| 408 | 408 | { |
| 409 | - if($localcheck) |
|
| 409 | + if ($localcheck) |
|
| 410 | 410 | { |
| 411 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 411 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 412 | 412 | { |
| 413 | 413 | $this->log->info('HTTP challenge for \'' . $identifier . '\' valid.'); |
| 414 | 414 | } |
| 415 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('HTTP challenge for \'' . $identifier . '\' valid.', 'function verifyPendingOrderAuthorization'); |
|
| 415 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('HTTP challenge for \'' . $identifier . '\' valid.', 'function verifyPendingOrderAuthorization'); |
|
| 416 | 416 | } |
| 417 | - while($auth->status == 'pending') |
|
| 417 | + while ($auth->status == 'pending') |
|
| 418 | 418 | { |
| 419 | 419 | sleep(1); |
| 420 | 420 | $auth->updateData(); |
@@ -424,30 +424,30 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | else |
| 426 | 426 | { |
| 427 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 427 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 428 | 428 | { |
| 429 | 429 | $this->log->info('HTTP challenge for \'' . $identifier . '\' tested locally, found invalid.'); |
| 430 | 430 | } |
| 431 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('HTTP challenge for \'' . $identifier . '\' tested locally, found invalid.', 'function verifyPendingOrderAuthorization'); |
|
| 431 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('HTTP challenge for \'' . $identifier . '\' tested locally, found invalid.', 'function verifyPendingOrderAuthorization'); |
|
| 432 | 432 | } |
| 433 | 433 | break; |
| 434 | 434 | case LEOrder::CHALLENGE_TYPE_DNS: |
| 435 | 435 | $DNSDigest = LEFunctions::Base64UrlSafeEncode(hash('sha256', $keyAuthorization, true)); |
| 436 | - if($localcheck == false OR LEFunctions::checkDNSChallenge($identifier, $DNSDigest)) |
|
| 436 | + if ($localcheck == false OR LEFunctions::checkDNSChallenge($identifier, $DNSDigest)) |
|
| 437 | 437 | { |
| 438 | 438 | $sign = $this->connector->signRequestKid(array('keyAuthorization' => $keyAuthorization), $this->connector->accountURL, $challenge['url']); |
| 439 | 439 | $post = $this->connector->post($challenge['url'], $sign); |
| 440 | - if($post['status'] === 200) |
|
| 440 | + if ($post['status'] === 200) |
|
| 441 | 441 | { |
| 442 | - if($localcheck) |
|
| 442 | + if ($localcheck) |
|
| 443 | 443 | { |
| 444 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 444 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 445 | 445 | { |
| 446 | 446 | $this->log->info('DNS challenge for \'' . $identifier . '\' valid.'); |
| 447 | 447 | } |
| 448 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('DNS challenge for \'' . $identifier . '\' valid.', 'function verifyPendingOrderAuthorization'); |
|
| 448 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('DNS challenge for \'' . $identifier . '\' valid.', 'function verifyPendingOrderAuthorization'); |
|
| 449 | 449 | } |
| 450 | - while($auth->status == 'pending') |
|
| 450 | + while ($auth->status == 'pending') |
|
| 451 | 451 | { |
| 452 | 452 | sleep(1); |
| 453 | 453 | $auth->updateData(); |
@@ -457,11 +457,11 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | else |
| 459 | 459 | { |
| 460 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 460 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 461 | 461 | { |
| 462 | 462 | $this->log->info('DNS challenge for \'' . $identifier . '\' tested locally, found invalid.'); |
| 463 | 463 | } |
| 464 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('DNS challenge for \'' . $identifier . '\' tested locally, found invalid.', 'function verifyPendingOrderAuthorization'); |
|
| 464 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('DNS challenge for \'' . $identifier . '\' tested locally, found invalid.', 'function verifyPendingOrderAuthorization'); |
|
| 465 | 465 | } |
| 466 | 466 | break; |
| 467 | 467 | } |
@@ -481,29 +481,29 @@ discard block |
||
| 481 | 481 | */ |
| 482 | 482 | public function deactivateOrderAuthorization($identifier) |
| 483 | 483 | { |
| 484 | - foreach($this->authorizations as $auth) |
|
| 484 | + foreach ($this->authorizations as $auth) |
|
| 485 | 485 | { |
| 486 | - if($auth->identifier['value'] == $identifier) |
|
| 486 | + if ($auth->identifier['value'] == $identifier) |
|
| 487 | 487 | { |
| 488 | 488 | $sign = $this->connector->signRequestKid(array('status' => 'deactivated'), $this->connector->accountURL, $auth->authorizationURL); |
| 489 | 489 | $post = $this->connector->post($auth->authorizationURL, $sign); |
| 490 | - if($post['status'] === 200) |
|
| 490 | + if ($post['status'] === 200) |
|
| 491 | 491 | { |
| 492 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 492 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 493 | 493 | { |
| 494 | 494 | $this->log->info('Authorization for \'' . $identifier . '\' deactivated.'); |
| 495 | 495 | } |
| 496 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Authorization for \'' . $identifier . '\' deactivated.', 'function deactivateOrderAuthorization'); |
|
| 496 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Authorization for \'' . $identifier . '\' deactivated.', 'function deactivateOrderAuthorization'); |
|
| 497 | 497 | $this->updateAuthorizations(); |
| 498 | 498 | return true; |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 502 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 503 | 503 | { |
| 504 | 504 | $this->log->info('No authorization found for \'' . $identifier . '\', cannot deactivate.'); |
| 505 | 505 | } |
| 506 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('No authorization found for \'' . $identifier . '\', cannot deactivate.', 'function deactivateOrderAuthorization'); |
|
| 506 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('No authorization found for \'' . $identifier . '\', cannot deactivate.', 'function deactivateOrderAuthorization'); |
|
| 507 | 507 | return false; |
| 508 | 508 | } |
| 509 | 509 | |
@@ -515,12 +515,12 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | public function generateCSR() |
| 517 | 517 | { |
| 518 | - $domains = array_map(function ($dns) { return $dns['value']; }, $this->identifiers); |
|
| 519 | - if(in_array($this->basename, $domains)) |
|
| 518 | + $domains = array_map(function($dns) { return $dns['value']; }, $this->identifiers); |
|
| 519 | + if (in_array($this->basename, $domains)) |
|
| 520 | 520 | { |
| 521 | 521 | $CN = $this->basename; |
| 522 | 522 | } |
| 523 | - elseif(in_array('*.' . $this->basename, $domains)) |
|
| 523 | + elseif (in_array('*.' . $this->basename, $domains)) |
|
| 524 | 524 | { |
| 525 | 525 | $CN = '*.' . $this->basename; |
| 526 | 526 | } |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | "commonName" => $CN |
| 534 | 534 | ); |
| 535 | 535 | |
| 536 | - $san = implode(",", array_map(function ($dns) { |
|
| 536 | + $san = implode(",", array_map(function($dns) { |
|
| 537 | 537 | return "DNS:" . $dns; |
| 538 | 538 | }, $domains)); |
| 539 | 539 | $tmpConf = tmpfile(); |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | $privateKey = openssl_pkey_get_private(file_get_contents($this->certificateKeys['private_key'])); |
| 559 | 559 | $csr = openssl_csr_new($dn, $privateKey, array('config' => $tmpConfPath, 'digest_alg' => 'sha256')); |
| 560 | - openssl_csr_export ($csr, $csr); |
|
| 560 | + openssl_csr_export($csr, $csr); |
|
| 561 | 561 | return $csr; |
| 562 | 562 | } |
| 563 | 563 | |
@@ -571,48 +571,48 @@ discard block |
||
| 571 | 571 | public function finalizeOrder($csr = '') |
| 572 | 572 | { |
| 573 | 573 | $this->updateOrderData(); |
| 574 | - if($this->status == 'ready') |
|
| 574 | + if ($this->status == 'ready') |
|
| 575 | 575 | { |
| 576 | - if($this->allAuthorizationsValid()) |
|
| 576 | + if ($this->allAuthorizationsValid()) |
|
| 577 | 577 | { |
| 578 | - if(empty($csr)) $csr = $this->generateCSR(); |
|
| 579 | - if(preg_match('~-----BEGIN\sCERTIFICATE\sREQUEST-----(.*)-----END\sCERTIFICATE\sREQUEST-----~s', $csr, $matches)) $csr = $matches[1]; |
|
| 578 | + if (empty($csr)) $csr = $this->generateCSR(); |
|
| 579 | + if (preg_match('~-----BEGIN\sCERTIFICATE\sREQUEST-----(.*)-----END\sCERTIFICATE\sREQUEST-----~s', $csr, $matches)) $csr = $matches[1]; |
|
| 580 | 580 | $csr = trim(LEFunctions::Base64UrlSafeEncode(base64_decode($csr))); |
| 581 | 581 | $sign = $this->connector->signRequestKid(array('csr' => $csr), $this->connector->accountURL, $this->finalizeURL); |
| 582 | 582 | $post = $this->connector->post($this->finalizeURL, $sign); |
| 583 | - if($post['status'] === 200) |
|
| 583 | + if ($post['status'] === 200) |
|
| 584 | 584 | { |
| 585 | 585 | $this->status = $post['body']['status']; |
| 586 | 586 | $this->expires = $post['body']['expires']; |
| 587 | 587 | $this->identifiers = $post['body']['identifiers']; |
| 588 | 588 | $this->authorizationURLs = $post['body']['authorizations']; |
| 589 | 589 | $this->finalizeURL = $post['body']['finalize']; |
| 590 | - if(array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 590 | + if (array_key_exists('certificate', $post['body'])) $this->certificateURL = $post['body']['certificate']; |
|
| 591 | 591 | $this->updateAuthorizations(); |
| 592 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 592 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 593 | 593 | { |
| 594 | 594 | $this->log->info('Order for \'' . $this->basename . '\' finalized.'); |
| 595 | 595 | } |
| 596 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' finalized.', 'function finalizeOrder'); |
|
| 596 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' finalized.', 'function finalizeOrder'); |
|
| 597 | 597 | return true; |
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | else |
| 601 | 601 | { |
| 602 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 602 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 603 | 603 | { |
| 604 | 604 | $this->log->info('Not all authorizations are valid for \'' . $this->basename . '\'. Cannot finalize order.'); |
| 605 | 605 | } |
| 606 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Not all authorizations are valid for \'' . $this->basename . '\'. Cannot finalize order.', 'function finalizeOrder'); |
|
| 606 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Not all authorizations are valid for \'' . $this->basename . '\'. Cannot finalize order.', 'function finalizeOrder'); |
|
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | else |
| 610 | 610 | { |
| 611 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 611 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 612 | 612 | { |
| 613 | 613 | $this->log->info('Order status for \'' . $this->basename . '\' is \'' . $this->status . '\'. Cannot finalize order.'); |
| 614 | 614 | } |
| 615 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order status for \'' . $this->basename . '\' is \'' . $this->status . '\'. Cannot finalize order.', 'function finalizeOrder'); |
|
| 615 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order status for \'' . $this->basename . '\' is \'' . $this->status . '\'. Cannot finalize order.', 'function finalizeOrder'); |
|
| 616 | 616 | } |
| 617 | 617 | return false; |
| 618 | 618 | } |
@@ -636,79 +636,79 @@ discard block |
||
| 636 | 636 | public function getCertificate() |
| 637 | 637 | { |
| 638 | 638 | $polling = 0; |
| 639 | - while($this->status == 'processing' && $polling < 4) |
|
| 639 | + while ($this->status == 'processing' && $polling < 4) |
|
| 640 | 640 | { |
| 641 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 641 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 642 | 642 | { |
| 643 | 643 | $this->log->info('Certificate for \'' . $this->basename . '\' being processed. Retrying in 5 seconds...'); |
| 644 | 644 | } |
| 645 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for \'' . $this->basename . '\' being processed. Retrying in 5 seconds...', 'function getCertificate'); |
|
| 645 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for \'' . $this->basename . '\' being processed. Retrying in 5 seconds...', 'function getCertificate'); |
|
| 646 | 646 | sleep(5); |
| 647 | 647 | $this->updateOrderData(); |
| 648 | 648 | $polling++; |
| 649 | 649 | } |
| 650 | - if($this->status == 'valid') |
|
| 650 | + if ($this->status == 'valid') |
|
| 651 | 651 | { |
| 652 | - if(!empty($this->certificateURL)) |
|
| 652 | + if (!empty($this->certificateURL)) |
|
| 653 | 653 | { |
| 654 | 654 | $sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->certificateURL); |
| 655 | 655 | $post = $this->connector->post($this->certificateURL, $sign); |
| 656 | - if($post['status'] === 200) |
|
| 656 | + if ($post['status'] === 200) |
|
| 657 | 657 | { |
| 658 | - if(preg_match_all('~(-----BEGIN\sCERTIFICATE-----[\s\S]+?-----END\sCERTIFICATE-----)~i', $post['body'], $matches)) |
|
| 658 | + if (preg_match_all('~(-----BEGIN\sCERTIFICATE-----[\s\S]+?-----END\sCERTIFICATE-----)~i', $post['body'], $matches)) |
|
| 659 | 659 | { |
| 660 | - if (isset($this->certificateKeys['certificate'])) file_put_contents($this->certificateKeys['certificate'], $matches[0][0]); |
|
| 660 | + if (isset($this->certificateKeys['certificate'])) file_put_contents($this->certificateKeys['certificate'], $matches[0][0]); |
|
| 661 | 661 | |
| 662 | - if(count($matches[0]) > 1 && isset($this->certificateKeys['fullchain_certificate'])) |
|
| 662 | + if (count($matches[0]) > 1 && isset($this->certificateKeys['fullchain_certificate'])) |
|
| 663 | 663 | { |
| 664 | - $fullchain = $matches[0][0]."\n"; |
|
| 665 | - for($i=1;$i<count($matches[0]);$i++) |
|
| 664 | + $fullchain = $matches[0][0] . "\n"; |
|
| 665 | + for ($i = 1; $i < count($matches[0]); $i++) |
|
| 666 | 666 | { |
| 667 | - $fullchain .= $matches[0][$i]."\n"; |
|
| 667 | + $fullchain .= $matches[0][$i] . "\n"; |
|
| 668 | 668 | } |
| 669 | 669 | file_put_contents(trim($this->certificateKeys['fullchain_certificate']), $fullchain); |
| 670 | 670 | } |
| 671 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 671 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 672 | 672 | { |
| 673 | 673 | $this->log->info('Certificate for \'' . $this->basename . '\' saved'); |
| 674 | 674 | } |
| 675 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for \'' . $this->basename . '\' saved', 'function getCertificate'); |
|
| 675 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for \'' . $this->basename . '\' saved', 'function getCertificate'); |
|
| 676 | 676 | return true; |
| 677 | 677 | } |
| 678 | 678 | else |
| 679 | 679 | { |
| 680 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 680 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 681 | 681 | { |
| 682 | 682 | $this->log->info('Received invalid certificate for \'' . $this->basename . '\'. Cannot save certificate.'); |
| 683 | 683 | } |
| 684 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Received invalid certificate for \'' . $this->basename . '\'. Cannot save certificate.', 'function getCertificate'); |
|
| 684 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Received invalid certificate for \'' . $this->basename . '\'. Cannot save certificate.', 'function getCertificate'); |
|
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | else |
| 688 | 688 | { |
| 689 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 689 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 690 | 690 | { |
| 691 | 691 | $this->log->info('Invalid response for certificate request for \'' . $this->basename . '\'. Cannot save certificate.'); |
| 692 | 692 | } |
| 693 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Invalid response for certificate request for \'' . $this->basename . '\'. Cannot save certificate.', 'function getCertificate'); |
|
| 693 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Invalid response for certificate request for \'' . $this->basename . '\'. Cannot save certificate.', 'function getCertificate'); |
|
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | 696 | else |
| 697 | 697 | { |
| 698 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 698 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 699 | 699 | { |
| 700 | 700 | $this->log->info('Order for \'' . $this->basename . '\' not valid. Cannot find certificate URL.'); |
| 701 | 701 | } |
| 702 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' not valid. Cannot find certificate URL.', 'function getCertificate'); |
|
| 702 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' not valid. Cannot find certificate URL.', 'function getCertificate'); |
|
| 703 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | else |
| 706 | 706 | { |
| 707 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 707 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 708 | 708 | { |
| 709 | 709 | $this->log->info('Order for \'' . $this->basename . '\' not valid. Cannot retrieve certificate.'); |
| 710 | 710 | } |
| 711 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' not valid. Cannot retrieve certificate.', 'function getCertificate'); |
|
| 711 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' not valid. Cannot retrieve certificate.', 'function getCertificate'); |
|
| 712 | 712 | } |
| 713 | 713 | return false; |
| 714 | 714 | } |
@@ -723,13 +723,13 @@ discard block |
||
| 723 | 723 | */ |
| 724 | 724 | public function revokeCertificate($reason = 0) |
| 725 | 725 | { |
| 726 | - if($this->status == 'valid' || $this->status == 'ready') |
|
| 726 | + if ($this->status == 'valid' || $this->status == 'ready') |
|
| 727 | 727 | { |
| 728 | 728 | if (isset($this->certificateKeys['certificate'])) $certFile = $this->certificateKeys['certificate']; |
| 729 | 729 | elseif (isset($this->certificateKeys['fullchain_certificate'])) $certFile = $this->certificateKeys['fullchain_certificate']; |
| 730 | 730 | else throw LEOrderException::InvalidConfigurationException('certificateKeys[certificate] or certificateKeys[fullchain_certificate] required'); |
| 731 | 731 | |
| 732 | - if(file_exists($certFile) && file_exists($this->certificateKeys['private_key'])) |
|
| 732 | + if (file_exists($certFile) && file_exists($this->certificateKeys['private_key'])) |
|
| 733 | 733 | { |
| 734 | 734 | $certificate = file_get_contents($this->certificateKeys['certificate']); |
| 735 | 735 | preg_match('~-----BEGIN\sCERTIFICATE-----(.*)-----END\sCERTIFICATE-----~s', $certificate, $matches); |
@@ -737,40 +737,40 @@ discard block |
||
| 737 | 737 | |
| 738 | 738 | $sign = $this->connector->signRequestJWK(array('certificate' => $certificate, 'reason' => $reason), $this->connector->revokeCert, $this->certificateKeys['private_key']); |
| 739 | 739 | $post = $this->connector->post($this->connector->revokeCert, $sign); |
| 740 | - if($post['status'] === 200) |
|
| 740 | + if ($post['status'] === 200) |
|
| 741 | 741 | { |
| 742 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 742 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 743 | 743 | { |
| 744 | 744 | $this->log->info('Certificate for order \'' . $this->basename . '\' revoked.'); |
| 745 | 745 | } |
| 746 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for order \'' . $this->basename . '\' revoked.', 'function revokeCertificate'); |
|
| 746 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for order \'' . $this->basename . '\' revoked.', 'function revokeCertificate'); |
|
| 747 | 747 | return true; |
| 748 | 748 | } |
| 749 | 749 | else |
| 750 | 750 | { |
| 751 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 751 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 752 | 752 | { |
| 753 | 753 | $this->log->info('Certificate for order \'' . $this->basename . '\' cannot be revoked.'); |
| 754 | 754 | } |
| 755 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for order \'' . $this->basename . '\' cannot be revoked.', 'function revokeCertificate'); |
|
| 755 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for order \'' . $this->basename . '\' cannot be revoked.', 'function revokeCertificate'); |
|
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | 758 | else |
| 759 | 759 | { |
| 760 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 760 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 761 | 761 | { |
| 762 | 762 | $this->log->info('Certificate for order \'' . $this->basename . '\' not found. Cannot revoke certificate.'); |
| 763 | 763 | } |
| 764 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for order \'' . $this->basename . '\' not found. Cannot revoke certificate.', 'function revokeCertificate'); |
|
| 764 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Certificate for order \'' . $this->basename . '\' not found. Cannot revoke certificate.', 'function revokeCertificate'); |
|
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | else |
| 768 | 768 | { |
| 769 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 769 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 770 | 770 | { |
| 771 | 771 | $this->log->info('Order for \'' . $this->basename . '\' not valid. Cannot revoke certificate.'); |
| 772 | 772 | } |
| 773 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' not valid. Cannot revoke certificate.', 'function revokeCertificate'); |
|
| 773 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Order for \'' . $this->basename . '\' not valid. Cannot revoke certificate.', 'function revokeCertificate'); |
|
| 774 | 774 | } |
| 775 | 775 | return false; |
| 776 | 776 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | private $log; |
| 52 | 52 | |
| 53 | - const LOG_OFF = 0; // Logs no messages or faults, except Runtime Exceptions. |
|
| 54 | - const LOG_STATUS = 1; // Logs only messages and faults. |
|
| 55 | - const LOG_DEBUG = 2; // Logs messages, faults and raw responses from HTTP requests. |
|
| 53 | + const LOG_OFF = 0; // Logs no messages or faults, except Runtime Exceptions. |
|
| 54 | + const LOG_STATUS = 1; // Logs only messages and faults. |
|
| 55 | + const LOG_DEBUG = 2; // Logs messages, faults and raw responses from HTTP requests. |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Initiates the LetsEncrypt main client. |
@@ -87,26 +87,26 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $certificateKeysDir = $certificateKeys; |
| 89 | 89 | |
| 90 | - if(!file_exists($certificateKeys)) |
|
| 90 | + if (!file_exists($certificateKeys)) |
|
| 91 | 91 | { |
| 92 | 92 | mkdir($certificateKeys, 0755, true); |
| 93 | 93 | LEFunctions::createhtaccess($certificateKeys); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $this->certificateKeys = array( |
| 97 | - "public_key" => $certificateKeys.'/public.pem', |
|
| 98 | - "private_key" => $certificateKeys.'/private.pem', |
|
| 99 | - "certificate" => $certificateKeys.'/certificate.crt', |
|
| 100 | - "fullchain_certificate" => $certificateKeys.'/fullchain.crt', |
|
| 101 | - "order" => $certificateKeys.'/order' |
|
| 97 | + "public_key" => $certificateKeys . '/public.pem', |
|
| 98 | + "private_key" => $certificateKeys . '/private.pem', |
|
| 99 | + "certificate" => $certificateKeys . '/certificate.crt', |
|
| 100 | + "fullchain_certificate" => $certificateKeys . '/fullchain.crt', |
|
| 101 | + "order" => $certificateKeys . '/order' |
|
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | elseif (is_array($certificateKeys)) |
| 105 | 105 | { |
| 106 | 106 | if (!isset($certificateKeys['certificate']) && !isset($certificateKeys['fullchain_certificate'])) throw LEClientException::InvalidArgumentException('certificateKeys[certificate] or certificateKeys[fullchain_certificate] file path must be set.'); |
| 107 | 107 | if (!isset($certificateKeys['private_key'])) throw LEClientException::InvalidArgumentException('certificateKeys[private_key] file path must be set.'); |
| 108 | - if (!isset($certificateKeys['order'])) $certificateKeys['order'] = dirname($certificateKeys['private_key']).'/order'; |
|
| 109 | - if (!isset($certificateKeys['public_key'])) $certificateKeys['public_key'] = dirname($certificateKeys['private_key']).'/public.pem'; |
|
| 108 | + if (!isset($certificateKeys['order'])) $certificateKeys['order'] = dirname($certificateKeys['private_key']) . '/order'; |
|
| 109 | + if (!isset($certificateKeys['public_key'])) $certificateKeys['public_key'] = dirname($certificateKeys['private_key']) . '/public.pem'; |
|
| 110 | 110 | |
| 111 | 111 | foreach ($certificateKeys as $param => $file) { |
| 112 | 112 | $parentDir = dirname($file); |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | if (is_string($accountKeys)) |
| 124 | 124 | { |
| 125 | - $accountKeys = $certificateKeysDir.'/'.$accountKeys; |
|
| 125 | + $accountKeys = $certificateKeysDir . '/' . $accountKeys; |
|
| 126 | 126 | |
| 127 | - if(!file_exists($accountKeys)) |
|
| 127 | + if (!file_exists($accountKeys)) |
|
| 128 | 128 | { |
| 129 | 129 | mkdir($accountKeys, 0755, true); |
| 130 | 130 | LEFunctions::createhtaccess($accountKeys); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $this->accountKeys = array( |
| 134 | - "private_key" => $accountKeys.'/private.pem', |
|
| 135 | - "public_key" => $accountKeys.'/public.pem' |
|
| 134 | + "private_key" => $accountKeys . '/private.pem', |
|
| 135 | + "public_key" => $accountKeys . '/public.pem' |
|
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | 138 | elseif (is_array($accountKeys)) |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | $this->connector = new LEConnector($this->log, $this->baseURL, $this->accountKeys); |
| 156 | 156 | $this->account = new LEAccount($this->connector, $this->log, $email, $this->accountKeys); |
| 157 | 157 | |
| 158 | - if($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 158 | + if ($this->log instanceof \Psr\Log\LoggerInterface) |
|
| 159 | 159 | { |
| 160 | 160 | $this->log->info('LEClient finished constructing'); |
| 161 | 161 | } |
| 162 | - elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('LEClient finished constructing', 'function LEClient __construct'); |
|
| 162 | + elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('LEClient finished constructing', 'function LEClient __construct'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | // Sets the maximum execution time to two minutes, to be sure. |
| 3 | 3 | ini_set('max_execution_time', 120); |
| 4 | 4 | // Including the autoloader. |
| 5 | -include __DIR__.'/../vendor/autoload.php'; |
|
| 5 | +include __DIR__ . '/../vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | // Importing the classes. |
| 8 | 8 | use LEClient\LEClient; |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | // Initiating the order instance. The keys and certificate will be stored in /example.org/ (argument 1) and the domains in the array (argument 2) will be on the certificate. |
| 21 | 21 | $order = $client->getOrCreateOrder($basename, $domains); |
| 22 | 22 | // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations. |
| 23 | -if(!$order->allAuthorizationsValid()) |
|
| 23 | +if (!$order->allAuthorizationsValid()) |
|
| 24 | 24 | { |
| 25 | 25 | // Get the DNS challenges from the pending authorizations. |
| 26 | 26 | $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS); |
| 27 | 27 | // Walk the list of pending authorization DNS challenges. |
| 28 | - if(!empty($pending)) |
|
| 28 | + if (!empty($pending)) |
|
| 29 | 29 | { |
| 30 | - foreach($pending as $challenge) |
|
| 30 | + foreach ($pending as $challenge) |
|
| 31 | 31 | { |
| 32 | 32 | // For the purpose of this example, a fictitious functions creates or updates the ACME challenge DNS record for this domain. |
| 33 | 33 | setDNSRecord($challenge['identifier'], $challenge['DNSDigest']); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | // Sets the maximum execution time to two minutes, to be sure. |
| 3 | 3 | ini_set('max_execution_time', 120); |
| 4 | 4 | // Including the autoloader. |
| 5 | -include __DIR__.'/../vendor/autoload.php'; |
|
| 5 | +include __DIR__ . '/../vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | // Importing the classes. |
| 8 | 8 | use LEClient\LEClient; |
@@ -20,19 +20,19 @@ discard block |
||
| 20 | 20 | // Initiating the order instance. The keys and certificate will be stored in /example.org/ (argument 1) and the domains in the array (argument 2) will be on the certificate. |
| 21 | 21 | $order = $client->getOrCreateOrder($basename, $domains); |
| 22 | 22 | // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations. |
| 23 | -if(!$order->allAuthorizationsValid()) |
|
| 23 | +if (!$order->allAuthorizationsValid()) |
|
| 24 | 24 | { |
| 25 | 25 | // Get the HTTP challenges from the pending authorizations. |
| 26 | 26 | $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_HTTP); |
| 27 | 27 | // Walk the list of pending authorization HTTP challenges. |
| 28 | - if(!empty($pending)) |
|
| 28 | + if (!empty($pending)) |
|
| 29 | 29 | { |
| 30 | - foreach($pending as $challenge) |
|
| 30 | + foreach ($pending as $challenge) |
|
| 31 | 31 | { |
| 32 | 32 | // Define the folder in which to store the challenge. For the purpose of this example, a fictitious path is set. |
| 33 | 33 | $folder = '/path/to/' . $challenge['identifier'] . '/.well-known/acme-challenge/'; |
| 34 | 34 | // Check if that directory yet exists. If not, create it. |
| 35 | - if(!file_exists($folder)) mkdir($folder, 0777, true); |
|
| 35 | + if (!file_exists($folder)) mkdir($folder, 0777, true); |
|
| 36 | 36 | // Store the challenge file for this domain. |
| 37 | 37 | file_put_contents($folder . $challenge['filename'], $challenge['content']); |
| 38 | 38 | // Let LetsEncrypt verify this challenge. |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | // Check once more whether all authorizations are valid before we can finalize the order. |
| 44 | -if($order->allAuthorizationsValid()) |
|
| 44 | +if ($order->allAuthorizationsValid()) |
|
| 45 | 45 | { |
| 46 | 46 | // Finalize the order first, if that is not yet done. |
| 47 | - if(!$order->isFinalized()) $order->finalizeOrder(); |
|
| 47 | + if (!$order->isFinalized()) $order->finalizeOrder(); |
|
| 48 | 48 | // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. |
| 49 | - if($order->isFinalized()) $order->getCertificate(); |
|
| 49 | + if ($order->isFinalized()) $order->getCertificate(); |
|
| 50 | 50 | } |
| 51 | 51 | ?> |
| 52 | 52 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | // Sets the maximum execution time to two minutes, to be sure. |
| 3 | 3 | ini_set('max_execution_time', 120); |
| 4 | 4 | // Including the autoloader. |
| 5 | -include __DIR__.'/../vendor/autoload.php'; |
|
| 5 | +include __DIR__ . '/../vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | // Importing the classes. |
| 8 | 8 | use LEClient\LEClient; |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | // Initiating the order instance. The keys and certificate will be stored in /example.org/ (argument 1) and the domains in the array (argument 2) will be on the certificate. |
| 21 | 21 | $order = $client->getOrCreateOrder($basename, $domains); |
| 22 | 22 | // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations. |
| 23 | -if(!$order->allAuthorizationsValid()) |
|
| 23 | +if (!$order->allAuthorizationsValid()) |
|
| 24 | 24 | { |
| 25 | 25 | // Get the DNS challenges from the pending authorizations. |
| 26 | 26 | $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS); |
| 27 | 27 | // Walk the list of pending authorization DNS challenges. |
| 28 | - if(!empty($pending)) |
|
| 28 | + if (!empty($pending)) |
|
| 29 | 29 | { |
| 30 | - foreach($pending as $challenge) |
|
| 30 | + foreach ($pending as $challenge) |
|
| 31 | 31 | { |
| 32 | 32 | // Let LetsEncrypt verify this challenge, which should have been fulfilled in exampleDNSStart.php. |
| 33 | 33 | $order->verifyPendingOrderAuthorization($challenge['identifier'], LEOrder::CHALLENGE_TYPE_DNS); |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | // Check once more whether all authorizations are valid before we can finalize the order. |
| 38 | -if($order->allAuthorizationsValid()) |
|
| 38 | +if ($order->allAuthorizationsValid()) |
|
| 39 | 39 | { |
| 40 | 40 | // Finalize the order first, if that is not yet done. |
| 41 | - if(!$order->isFinalized()) $order->finalizeOrder(); |
|
| 41 | + if (!$order->isFinalized()) $order->finalizeOrder(); |
|
| 42 | 42 | // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. |
| 43 | - if($order->isFinalized()) $order->getCertificate(); |
|
| 43 | + if ($order->isFinalized()) $order->getCertificate(); |
|
| 44 | 44 | } |
| 45 | 45 | ?> |
| 46 | 46 | \ No newline at end of file |