From 6c1fa9446173ff6bb41934d3ad07f9b960c2c0c4 Mon Sep 17 00:00:00 2001 From: yourivw Date: Sun, 20 Jun 2021 12:51:42 +0200 Subject: [PATCH] Fixed new sourceIp argument, added doc --- src/LEClient.php | 3 ++- src/LEConnector.php | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/LEClient.php b/src/LEClient.php index d45236c..1b6b7d2 100644 --- a/src/LEClient.php +++ b/src/LEClient.php @@ -66,11 +66,12 @@ class LEClient * @param array $certificateKeys Optional array containing location of all certificate files. Required paths are public_key, private_key, order and certificate/fullchain_certificate (you can use both or only one of them) * @param string $accountKeys The directory in which the account keys are stored. Is a subdir inside $certificateKeys. Defaults to '__account/'.(optional) * @param array $accountKeys Optional array containing location of account private and public keys. Required paths are private_key, public_key. + * @param string $sourceIp Optional source IP address. */ public function __construct($email, $acmeURL = LEClient::LE_PRODUCTION, $log = LEClient::LOG_OFF, $certificateKeys = 'keys/', $accountKeys = '__account/', $sourceIp = false) { $this->log = $log; - $this->sourceIp = false; + $this->sourceIp = $sourceIp; if (is_bool($acmeURL)) { if ($acmeURL === true) $this->baseURL = LEClient::LE_STAGING; diff --git a/src/LEConnector.php b/src/LEConnector.php index 2733477..1f3631e 100644 --- a/src/LEConnector.php +++ b/src/LEConnector.php @@ -46,7 +46,7 @@ class LEConnector public $keyChange; public $newAccount; - public $newNonce; + public $newNonce; public $newOrder; public $revokeCert; @@ -56,12 +56,14 @@ class LEConnector private $log; private $sourceIp = false; + /** * Initiates the LetsEncrypt Connector class. * * @param int $log The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted. * @param string $baseURL The LetsEncrypt server URL to make requests to. * @param array $accountKeys Array containing location of account keys files. + * @param string $sourceIp Optional source IP address. */ public function __construct($log, $baseURL, $accountKeys, $sourceIp = false) { @@ -70,7 +72,7 @@ public function __construct($log, $baseURL, $accountKeys, $sourceIp = false) $this->log = $log; $this->getLEDirectory(); $this->getNewNonce(); - $this->sourceIp = false; + $this->sourceIp = $sourceIp; } /** @@ -114,9 +116,10 @@ private function request($method, $URL, $data = null) curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_HEADER, true); - if($this->sourceIp !== false) { - curl_setopt($handle, CURLOPT_INTERFACE, $this->sourceIp); - } + if($this->sourceIp !== false) { + curl_setopt($handle, CURLOPT_INTERFACE, $this->sourceIp); + } + switch ($method) { case 'GET': break;