Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Fixed new sourceIp argument, added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yourivw committed Jun 20, 2021
1 parent 6ceab6a commit 6c1fa94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/LEClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 8 additions & 5 deletions src/LEConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LEConnector

public $keyChange;
public $newAccount;
public $newNonce;
public $newNonce;
public $newOrder;
public $revokeCert;

Expand All @@ -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)
{
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6c1fa94

Please sign in to comment.