Skip to content

Commit

Permalink
Reverted to symlink based .well-known (required by certbot configurat…
Browse files Browse the repository at this point in the history
…ion)
  • Loading branch information
jkphl committed Dec 11, 2017
1 parent e453c59 commit e79cc59
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/Admin/Infrastructure/Persistence/Apache.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function __construct(AccountInterface $account, array $config)
public function __invoke(VhostInterface $vhost)
{
$files = [];
$httpsPorts = $vhost->getPorts(Vhost::PROTOCOL_HTTPS);

$variables = $this->config;
$variables['primary_domain'] = strval($vhost->getPrimaryDomain());
Expand All @@ -110,8 +109,6 @@ public function __invoke(VhostInterface $vhost)
rtrim($this->config['dataroot'].DIRECTORY_SEPARATOR.$vhost->getDocroot(), DIRECTORY_SEPARATOR);
$variables['configroot'] = $this->config['vhostroot'].DIRECTORY_SEPARATOR.$variables['primary_domain'];
$variables['php_version'] = $vhost->getPhp();
$variables['challenge'] = rtrim(App::getConfig('certbot.challenge'), '/').'/';
$variables['ssl'] = !empty($httpsPorts);

// If the virtual host should redirect
if ($vhost->getRedirectUrl() !== null) {
Expand All @@ -130,6 +127,7 @@ public function __invoke(VhostInterface $vhost)
TemplateService::render('apache_vhost.include', $variables));

// If the HTTPS protocol is supported
$httpsPorts = $vhost->getPorts(Vhost::PROTOCOL_HTTPS);
if (!empty($httpsPorts)) {
$certbotConfig = $this->helper->vhostDirectory($vhost).DIRECTORY_SEPARATOR.'certbot.ini';
$certbotService = CertbotServiceFactory::create($certbotConfig);
Expand Down Expand Up @@ -157,8 +155,7 @@ public function __invoke(VhostInterface $vhost)
TemplateService::render('certbot.ini', $variables));

// Create the well-known symlink
// 2017-12-11: Disabled again, see deprecation notice
// $certbotService->prepare($vhost, $this->helper);
$certbotService->prepare($vhost, $this->helper);

// Output a hint if the primary domain isn't certified
if (!$primaryDomainIsCertified) {
Expand Down
1 change: 0 additions & 1 deletion src/Admin/Infrastructure/Service/CertbotService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public function isCertified($domain)
* @throws \RuntimeException If the Certbot challenge directory is invalid
* @throws \RuntimeException If the well-known symlink cannot be created
* @throws \RuntimeException If the well-known link exists but is invalid
* @deprecated There should be no need for a real symlink here, the Apache Alias should cater for this
*/
public function prepare(VhostInterface $vhost, AccountHelper $accountHelper)
{
Expand Down
8 changes: 1 addition & 7 deletions src/Admin/Infrastructure/Templates/apache_vhost.include
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ DocumentRoot "{{docroot}}"
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>{{#ssl}}

<Directory {{challenge}}>
AllowOverride None
Require all granted
</Directory>
Alias /.well-known/ {{challenge}}/{{/ssl}}{{#php_version}}
</Directory>{{#php_version}}

Include {{configroot}}/apache_fmp.include{{/php_version}}
2 changes: 1 addition & 1 deletion src/Admin/Infrastructure/Templates/certbot.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
domains = {{primary_domain}}{{#secondary_domains_without_wildcards}},{{secondary_domains_without_wildcards}}{{/secondary_domains_without_wildcards}}
webroot-path = {{challenge}}
webroot-path = {{docroot}}

rsa-key-size = 4096
email = {{certemail}}
Expand Down

0 comments on commit e79cc59

Please sign in to comment.