Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Apr 9, 2017
1 parent 06ebc87 commit d367996
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ $forge->deleteCertificate($serverId, $siteId, $certificateId);
$forge->getCertificateSigningRequest($serverId, $siteId, $certificateId);
$forge->installCertificate($serverId, $siteId, $certificateId, $wait = true);
$forge->activateCertificate($serverId, $siteId, $certificateId, $wait = true);
$forge->obtainLetsEncryptCertificate($serverId, $siteId, $data);
$forge->obtainLetsEncryptCertificate($serverId, $siteId, $data, $wait = true);
```

On a Certificate Instance you may also call:
Expand Down
21 changes: 15 additions & 6 deletions src/Actions/ManagesCertificates.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,22 @@ public function activateCertificate($serverId, $siteId, $certificateId, $wait =
*
* @param integer $serverId
* @param integer $siteId
* @param array $data Array of the domains obtain certificates for
* @param array $data
* @param boolean $wait
* @return Certificate
*/
public function obtainLetsEncryptCertificate($serverId, $siteId, array $data)
{
$certificate = $this->post("servers/$serverId/sites/$siteId/certificates/letsencrypt", ['domains' => $data])['certificate'];
public function obtainLetsEncryptCertificate($serverId, $siteId, array $data, $wait = true)
{
$certificate = $this->post("servers/$serverId/sites/$siteId/certificates/letsencrypt", $data)['certificate'];

if ($wait) {
return $this->retry(30, function () use ($serverId, $siteId, $certificate) {
$certificate = $this->certificate($serverId, $siteId, $certificate['id']);

return new Certificate($certificate + ['server_id' => $serverId, 'site_id' => $siteId], $this);
}
return $certificate->status == 'installed' ? $certificate : null;
});
}

return new Certificate($certificate + ['server_id' => $serverId, 'site_id' => $siteId], $this);
}
}

0 comments on commit d367996

Please sign in to comment.