|
@@ -5,6 +5,7 @@ namespace Modules\LetsEncrypt\Listeners;
|
|
use App\ApiClient;
|
|
use App\ApiClient;
|
|
use App\Events\HostingAccountIsCreated;
|
|
use App\Events\HostingAccountIsCreated;
|
|
use App\FileManagerApi;
|
|
use App\FileManagerApi;
|
|
|
|
+use App\Models\WebsiteSslCertificate;
|
|
use App\Settings;
|
|
use App\Settings;
|
|
use App\ShellApi;
|
|
use App\ShellApi;
|
|
|
|
|
|
@@ -41,11 +42,49 @@ class HostingAccountIsCreatedListener
|
|
$amePHPPharFile = base_path() . '/Modules/LetsEncrypt/Actions/acmephp.phar';
|
|
$amePHPPharFile = base_path() . '/Modules/LetsEncrypt/Actions/acmephp.phar';
|
|
|
|
|
|
$phyrePHP = ApiClient::getPhyrePHP();
|
|
$phyrePHP = ApiClient::getPhyrePHP();
|
|
- $command = $phyrePHP . ' ' . $amePHPPharFile . ' run ' . $event->model->domain_root . '/acme-config.yaml';
|
|
|
|
- $execPhar = ShellApi::exec($command);
|
|
|
|
|
|
+ $phyrePHP = 'php';
|
|
|
|
|
|
|
|
+// $command = $phyrePHP . ' ' . $amePHPPharFile . ' run ' . $event->model->domain_root . '/acme-config.yaml';
|
|
|
|
+// $execPhar = ShellApi::exec($command);
|
|
|
|
|
|
- dd($execPhar);
|
|
|
|
|
|
+
|
|
|
|
+ $validateCertificates = [];
|
|
|
|
+ $sslCertificateFilePath = '/root/.acmephp/master/certs/'.$event->model->domain.'/public/cert.pem';
|
|
|
|
+ $sslCertificateKeyFilePath = '/root/.acmephp/master/certs/'.$event->model->domain.'/private/key.private.pem';
|
|
|
|
+ $sslCertificateChainFilePath = '/root/.acmephp/master/certs/'.$event->model->domain.'/public/fullchain.pem';
|
|
|
|
+
|
|
|
|
+ $sslCertificateFileContent = $fmApi->fileGetContents($sslCertificateFilePath);
|
|
|
|
+ $sslCertificateKeyFileContent = $fmApi->fileGetContents($sslCertificateKeyFilePath);
|
|
|
|
+ $sslCertificateChainFileContent = $fmApi->fileGetContents($sslCertificateChainFilePath);
|
|
|
|
+
|
|
|
|
+ if (!empty($sslCertificateChainFileContent)) {
|
|
|
|
+ $validateCertificates['certificate'] = $sslCertificateFileContent;
|
|
|
|
+ }
|
|
|
|
+ if (!empty($sslCertificateKeyFileContent)) {
|
|
|
|
+ $validateCertificates['private_key'] = $sslCertificateKeyFileContent;
|
|
|
|
+ }
|
|
|
|
+ if (!empty($sslCertificateChainFileContent)) {
|
|
|
|
+ $validateCertificates['certificate_chain'] = $sslCertificateChainFileContent;
|
|
|
|
+ }
|
|
|
|
+ if (count($validateCertificates) !== 3) {
|
|
|
|
+ // Cant get all certificates
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $websiteSslCertificate = new WebsiteSslCertificate();
|
|
|
|
+ $websiteSslCertificate->domain = $event->model->domain;
|
|
|
|
+ $websiteSslCertificate->certificate = $validateCertificates['certificate'];
|
|
|
|
+ $websiteSslCertificate->private_key = $validateCertificates['private_key'];
|
|
|
|
+ $websiteSslCertificate->certificate_chain = $validateCertificates['certificate_chain'];
|
|
|
|
+ $websiteSslCertificate->user_id = $event->model->user_id;
|
|
|
|
+ $websiteSslCertificate->is_active = 1;
|
|
|
|
+ $websiteSslCertificate->is_wildcard = 0;
|
|
|
|
+ $websiteSslCertificate->is_auto_renew = 1;
|
|
|
|
+ $websiteSslCertificate->save();
|
|
|
|
+
|
|
|
|
+ dd($sslCertificateFileContent);
|
|
|
|
+
|
|
|
|
+ dd(1);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|