This commit is contained in:
Bozhidar 2024-08-05 16:40:06 +03:00
parent ee90204394
commit 42f850fef0
4 changed files with 21 additions and 23 deletions

View file

@ -1,9 +0,0 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArRmu5WOZsz50RBvtUU05
wZ66jQrAjmJ4t9Kj2+iaynX5OY05d9dH9v+JF9x6dCo+D6dSJLcAyA4/Cosq3TW/
rDVSY9eIUsuxr4OlmguFLfHa9vML9Ot1f/z/4uxXhUuG1w15TkqhIvxbHdMes0mH
5nA54uHVki5RSQrN08ebawBkxRbp/gG7qvMPxNhBdyTwZ6T7TUJSDWqZYzS6XcjR
F1qzOhucAo1lqT7B2XBGYdsEHngZNTVlc4VAdj2ZajOSJdEYsOoxXGV20JFS22lr
I1a4Sp6jm9stBuagttfsI5c2kTplfpMbGEDsj+jeNwY7rFfghy4d0G1xZQKarcBO
iQIDAQAB
-----END PUBLIC KEY-----

View file

@ -0,0 +1,9 @@
sudo certbot certonly \
--non-interactive \
--agree-tos \
--manual \
--preferred-challenges=http \
-d {{$domain}} \
--email {{$email}} \
--manual-auth-hook /usr/local/phyre/web/Modules/LetsEncrypt/shell/hooks/pre/http-authenticator.sh \
--force-renewal

View file

@ -37,9 +37,18 @@ Route::post('letsencrypt/secure', function () {
return response()->json(['error' => 'Domain already secured'], 400);
}
$findHostingSubscription = \App\Models\HostingSubscription::where('id', $findDomain->hosting_subscription_id)->first();
if (! $findHostingSubscription) {
return response()->json(['error' => 'Domain not hosted'], 400);
}
$generalSettings = Settings::general();
$acmeConfigYaml = view('letsencrypt::actions.acme-config-yaml', [
$sslCertificateFilePath = '/etc/letsencrypt/live/'.$findDomain->domain.'/cert.pem';
$sslCertificateKeyFilePath = '/etc/letsencrypt/live/'.$findDomain->domain.'/privkey.pem';
$sslCertificateChainFilePath = '/etc/letsencrypt/live/'.$findDomain->domain.'/fullchain.pem';
$certbotHttpSecureCommand = view('letsencrypt::actions.certbot-http-secure-command', [
'domain' => $findDomain->domain,
'domainRoot' => $findDomain->domain_root,
'domainPublic' => $findDomain->domain_public,
@ -49,26 +58,15 @@ Route::post('letsencrypt/secure', function () {
'organization' => $generalSettings['organization_name'],
])->render();
file_put_contents($findDomain->domain_root.'/acme-config.yaml', $acmeConfigYaml);
$amePHPPharFile = base_path().'/Modules/LetsEncrypt/Actions/acmephp.phar';
$phyrePHP = ApiClient::getPhyrePHP();
$command = $phyrePHP.' '.$amePHPPharFile.' run '.$findDomain->domain_root.'/acme-config.yaml';
$execSSL = shell_exec($command);
$exec = shell_exec($certbotHttpSecureCommand);
$validateCertificates = [];
$sslCertificateFilePath = '/root/.acmephp/master/certs/'.$findDomain->domain.'/public/cert.pem';
$sslCertificateKeyFilePath = '/root/.acmephp/master/certs/'.$findDomain->domain.'/private/key.private.pem';
$sslCertificateChainFilePath = '/root/.acmephp/master/certs/'.$findDomain->domain.'/public/fullchain.pem';
if (! file_exists($sslCertificateFilePath)
|| ! file_exists($sslCertificateKeyFilePath)
|| ! file_exists($sslCertificateChainFilePath)) {
// Cant get all certificates
return;
return response()->json(['error' => 'Cant get all certificates'], 400);
}
$sslCertificateFileContent = file_get_contents($sslCertificateFilePath);