This repository has been archived by the owner on Mar 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.2.0: - Added custom exceptions per class, with multiple specific exception codes per exception. All exceptions are extended from LEException, which is extended from RuntimeException, and therefore backwards compatible. Response data (request, header, status, body) is added when LEConnectorException::InvalidResponseException is thrown. - All GET requests, except from the initial /directory request, are changed to POST-as-GET requests to comply with ACME changes. This also resolves current related issues when using the staging endpoint. - Bugfix in LEAccount->updateAccount(), implemented isset check for $post['body']['id'] similair to LEAccount->getLEAccountData(). - Bugfix in LEAccount->deactivateAccount(), now returns true after deactivation. - Change in LEOrder setup parameter check (notBefore and notAfter). - Example code endpoint changed to staging endpoint. - All code has been extensively tested again.
- Loading branch information
Showing
17 changed files
with
548 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace LEClient\Exceptions; | ||
|
||
/** | ||
* LetsEncrypt Client Account exception, extends LEException | ||
* | ||
* PHP version 5.2.0 | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Youri van Weegberg | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* @author Youri van Weegberg <[email protected]> | ||
* @copyright 2020 Youri van Weegberg | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* @link https://github.com/yourivw/LEClient | ||
* @since Class available since Release 1.2.0 | ||
*/ | ||
class LEAccountException extends LEException | ||
{ | ||
public const ACCOUNTNOTFOUNDEEXCEPTION = 0x21; | ||
|
||
public static function AccountNotFoundException() | ||
{ | ||
return new static('Account not found or deactivated.', self::ACCOUNTNOTFOUNDEEXCEPTION); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace LEClient\Exceptions; | ||
|
||
/** | ||
* LetsEncrypt Client Authorization exception, extends LEException | ||
* | ||
* PHP version 5.2.0 | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Youri van Weegberg | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* @author Youri van Weegberg <[email protected]> | ||
* @copyright 2020 Youri van Weegberg | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* @link https://github.com/yourivw/LEClient | ||
* @since Class available since Release 1.2.0 | ||
*/ | ||
class LEAuthorizationException extends LEException | ||
{ | ||
public const NOCHALLENGEFOUNDEEXCEPTION = 0x41; | ||
|
||
public static function NoChallengeFoundException($type, $identifier) | ||
{ | ||
return new static(sprintf('No challenge found for type \'%s\' and identifier \'%s\'.', $type, $identifier), self::NOCHALLENGEFOUNDEEXCEPTION); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace LEClient\Exceptions; | ||
|
||
/** | ||
* LetsEncrypt Client exception, extends LEException | ||
* | ||
* PHP version 5.2.0 | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Youri van Weegberg | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* @author Youri van Weegberg <[email protected]> | ||
* @copyright 2020 Youri van Weegberg | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* @link https://github.com/yourivw/LEClient | ||
* @since Class available since Release 1.2.0 | ||
*/ | ||
class LEClientException extends LEException | ||
{ | ||
public const INVALIDARGUMENTEXCEPTION = 0x01; | ||
public const INVALIDDIRECTORYEXCEPTION = 0x02; | ||
|
||
public static function InvalidArgumentException(string $message) | ||
{ | ||
return new static($message, self::INVALIDARGUMENTEXCEPTION); | ||
} | ||
|
||
public static function InvalidDirectoryException(string $directory) | ||
{ | ||
return new static(sprintf('%s directory not found.', $directory), self::INVALIDDIRECTORYEXCEPTION); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace LEClient\Exceptions; | ||
|
||
/** | ||
* LetsEncrypt Client Connector exception, extends LEException | ||
* | ||
* PHP version 5.2.0 | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Youri van Weegberg | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* @author Youri van Weegberg <[email protected]> | ||
* @copyright 2020 Youri van Weegberg | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* @link https://github.com/yourivw/LEClient | ||
* @since Class available since Release 1.2.0 | ||
*/ | ||
class LEConnectorException extends LEException | ||
{ | ||
public const NONEWNONCEEXCEPTION = 0x11; | ||
public const ACCOUNTDEACTIVATEDEXCEPTION = 0x12; | ||
public const METHODNOTSUPPORTEDEXCEPTION = 0x13; | ||
public const CURLERROREXCEPTION = 0x14; | ||
public const INVALIDRESPONSEEXCEPTION = 0x15; | ||
|
||
public static function NoNewNonceException() | ||
{ | ||
return new static('No new nonce.', self::NONEWNONCEEXCEPTION); | ||
} | ||
|
||
public static function AccountDeactivatedException() | ||
{ | ||
return new static('The account was deactivated. No further requests can be made.', self::ACCOUNTDEACTIVATEDEXCEPTION); | ||
} | ||
|
||
public static function MethodNotSupportedException(string $method) | ||
{ | ||
return new static(sprintf('HTTP request %s not supported.', $method), self::METHODNOTSUPPORTEDEXCEPTION); | ||
} | ||
|
||
public static function CurlErrorException(string $error) | ||
{ | ||
return new static(sprintf('Curl error: %s', $error), self::CURLERROREXCEPTION); | ||
} | ||
|
||
public static function InvalidResponseException(array $response) | ||
{ | ||
$statusCode = array_key_exists('status', $response) ? $response['status'] : 'unknown'; | ||
return new static(sprintf('Invalid response: %s', $statusCode), self::INVALIDRESPONSEEXCEPTION, null, $response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace LEClient\Exceptions; | ||
|
||
/** | ||
* LetsEncrypt Client base exception, extends PHP's RuntimeException. | ||
* | ||
* PHP version 5.2.0 | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Youri van Weegberg | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* @author Youri van Weegberg <[email protected]> | ||
* @copyright 2020 Youri van Weegberg | ||
* @license https://opensource.org/licenses/mit-license.php MIT License | ||
* @link https://github.com/yourivw/LEClient | ||
* @since Class available since Release 1.2.0 | ||
*/ | ||
class LEException extends \RuntimeException | ||
{ | ||
protected $responsedata; | ||
|
||
public function __construct(string $message = "", int $code = 0, Throwable $previous = NULL, array $responsedata = NULL) | ||
{ | ||
parent::__construct($message, $code, $previous); | ||
$this->responsedata = $responsedata; | ||
} | ||
|
||
public function getResponseData(): ?array | ||
{ | ||
return $this->responsedata; | ||
} | ||
} |
Oops, something went wrong.