Merge pull request #378 from oliverrahner/patch-1
Remove dependency on hard coded agreement URL for Let's Encrypt
This commit is contained in:
@@ -30,7 +30,7 @@ class lescript
|
|||||||
{
|
{
|
||||||
|
|
||||||
// https://letsencrypt.org/repository/
|
// https://letsencrypt.org/repository/
|
||||||
public $license = 'https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf';
|
public $license;
|
||||||
|
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
@@ -79,8 +79,9 @@ class lescript
|
|||||||
if ($this->client->getLastCode() != 201) {
|
if ($this->client->getLastCode() != 201) {
|
||||||
throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . json_encode($response));
|
throw new \RuntimeException("Account not initialized, probably due to rate limiting. Whole response: " . json_encode($response));
|
||||||
}
|
}
|
||||||
|
$this->license = $this->client->getAgreementURL();
|
||||||
$this->postNewReg();
|
|
||||||
|
$this->postRegAgreement(parse_url($this->client->getLastLocation(), PHP_URL_PATH));
|
||||||
$this->log('New account certificate registered');
|
$this->log('New account certificate registered');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -316,6 +317,16 @@ class lescript
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function postRegAgreement($uri)
|
||||||
|
{
|
||||||
|
$this->log('Accepting agreement at URL: ' . $this->license);
|
||||||
|
|
||||||
|
return $this->signedRequest($uri, array(
|
||||||
|
'resource' => 'reg',
|
||||||
|
'agreement' => $this->license
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
private function generateCSR($privateKey, array $domains)
|
private function generateCSR($privateKey, array $domains)
|
||||||
{
|
{
|
||||||
$domain = reset($domains);
|
$domain = reset($domains);
|
||||||
@@ -517,6 +528,13 @@ class Client
|
|||||||
preg_match_all('~Link: <(.+)>;rel="up"~', $this->lastHeader, $matches);
|
preg_match_all('~Link: <(.+)>;rel="up"~', $this->lastHeader, $matches);
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAgreementURL()
|
||||||
|
{
|
||||||
|
preg_match_all('~Link: <(.+)>;rel="terms-of-service"~', $this->lastHeader, $matches);
|
||||||
|
return $matches[1][0];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Base64UrlSafeEncoder
|
class Base64UrlSafeEncoder
|
||||||
|
|||||||
Reference in New Issue
Block a user