Skip to content

Made all private methods/fields protected #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Lescript.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class Lescript
public $contact = array(); // optional
// public $contact = array("mailto:cert-admin@example.com", "tel:+12025551212")

private $certificatesDir;
private $webRootDir;
protected $certificatesDir;
protected $webRootDir;

/** @var \Psr\Log\LoggerInterface */
private $logger;
private $client;
private $accountKeyPath;
protected $logger;
protected $client;
protected $accountKeyPath;

public function __construct($certificatesDir, $webRootDir, $logger = null, ClientInterface $client = null)
{
Expand Down Expand Up @@ -226,7 +226,7 @@ public function signDomains(array $domains, $reuseCsr = false)
$this->log("Done !!§§!");
}

private function readPrivateKey($path)
protected function readPrivateKey($path)
{
if (($key = openssl_pkey_get_private('file://' . $path)) === FALSE) {
throw new \RuntimeException(openssl_error_string());
Expand All @@ -235,18 +235,18 @@ private function readPrivateKey($path)
return $key;
}

private function parsePemFromBody($body)
protected function parsePemFromBody($body)
{
$pem = chunk_split(base64_encode($body), 64, "\n");
return "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n";
}

private function getDomainPath($domain)
protected function getDomainPath($domain)
{
return $this->certificatesDir . '/' . $domain . '/';
}

private function postNewReg()
protected function postNewReg()
{
$this->log('Sending registration to letsencrypt server');

Expand All @@ -261,7 +261,7 @@ private function postNewReg()
);
}

private function generateCSR($privateKey, array $domains)
protected function generateCSR($privateKey, array $domains)
{
$domain = reset($domains);
$san = implode(",", array_map(function ($dns) {
Expand Down Expand Up @@ -312,15 +312,15 @@ private function generateCSR($privateKey, array $domains)
return $this->getCsrContent($csrPath);
}

private function getCsrContent($csrPath) {
protected function getCsrContent($csrPath) {
$csr = file_get_contents($csrPath);

preg_match('~REQUEST-----(.*)-----END~s', $csr, $matches);

return trim(Base64UrlSafeEncoder::encode(base64_decode($matches[1])));
}

private function generateKey($outputDirectory)
protected function generateKey($outputDirectory)
{
$res = openssl_pkey_new(array(
"private_key_type" => OPENSSL_KEYTYPE_RSA,
Expand All @@ -340,7 +340,7 @@ private function generateKey($outputDirectory)
file_put_contents($outputDirectory.'/public.pem', $details['key']);
}

private function signedRequest($uri, array $payload)
protected function signedRequest($uri, array $payload)
{
$privateKey = $this->readPrivateKey($this->accountKeyPath);
$details = openssl_pkey_get_details($privateKey);
Expand Down Expand Up @@ -441,17 +441,17 @@ public function getLastLinks();

class Client implements ClientInterface
{
private $lastCode;
private $lastHeader;
protected $lastCode;
protected $lastHeader;

private $base;
protected $base;

public function __construct($base)
{
$this->base = $base;
}

private function curl($method, $url, $data = null)
protected function curl($method, $url, $data = null)
{
$headers = array('Accept: application/json', 'Content-Type: application/json');
$handle = curl_init();
Expand Down