Implement global CAA settings

This commit is contained in:
Marc-André Kolly
2019-07-28 19:49:32 +02:00
parent 358ca61a26
commit 240178eba7
6 changed files with 45 additions and 22 deletions

View File

@@ -107,6 +107,22 @@ return array(
'default' => false,
'save_method' => 'storeSettingField'
),
'system_dns_createcaaentry' => array(
'label' => $lng['serversettings']['caa_entry'],
'settinggroup' => 'system',
'varname' => 'dns_createcaaentry',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField'
),
'caa.caa_entry' => array(
'label' => $lng['serversettings']['caa_entry_custom'],
'settinggroup' => 'caa',
'varname' => 'caa_entry',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField'
),
'system_defaultttl' => array(
'label' => $lng['serversettings']['defaultttl'],
'settinggroup' => 'system',

View File

@@ -256,7 +256,6 @@ CREATE TABLE `panel_domains` (
`mod_fcgid_maxrequests` int(4) default '-1',
`ismainbutsubto` int(11) unsigned NOT NULL default '0',
`letsencrypt` tinyint(1) NOT NULL default '0',
`caa` text default NULL,
`hsts` varchar(10) NOT NULL default '0',
`hsts_sub` tinyint(1) NOT NULL default '0',
`hsts_preload` tinyint(1) NOT NULL default '0',
@@ -376,6 +375,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('admin', 'show_news_feed', '0'),
('admin', 'show_version_login', '0'),
('admin', 'show_version_footer', '0'),
('caa', 'caa_entry', ''),
('spf', 'use_spf', '0'),
('spf', 'spf_entry', '"v=spf1 a mx -all"'),
('dkim', 'dkim_algorithm', 'all'),
@@ -562,6 +562,7 @@ opcache.interned_strings_buffer'),
('system', 'mod_fcgid_defaultini', '1'),
('system', 'ftpserver', 'proftpd'),
('system', 'dns_createmailentry', '0'),
('system', 'dns_createcaaentry', '1'),
('system', 'froxlordirectlyviahostname', '0'),
('system', 'report_enable', '1'),
('system', 'report_webmax', '90'),

View File

@@ -266,8 +266,9 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.0-rc1')) {
if (\Froxlor\Froxlor::isDatabaseVersion('201904250')) {
showUpdateStep("Adding field caa for domains");
Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD `caa` text default NULL AFTER `letsencrypt`;");
showUpdateStep("Adding new settings for CAA");
Settings::AddNew('caa.caa_entry', '', true);
Settings::AddNew('system.dns_createcaaentry', 1, true);
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('201907270');

View File

@@ -131,15 +131,9 @@ class Dns
}
// additional required records for CAA if activated
if (!is_null($domain['caa'])) {
if (Settings::Get('system.dns_createcaaentry') && Settings::Get('system.use_ssl') == "1" && !empty($domain['p_ssl_ipandports'])) {
// check for CAA content later
self::addRequiredEntry('@', 'CAA', $required_entries);
// additional required records by subdomain setting
if ($domain['iswildcarddomain'] == '1') {
self::addRequiredEntry('*', 'CAA', $required_entries);
} elseif ($domain['wwwserveralias'] == '1') {
self::addRequiredEntry('www', 'CAA', $required_entries);
}
self::addRequiredEntry('@CAA@', 'CAA', $required_entries);
}
// additional required records for SPF and DKIM if activated
@@ -162,6 +156,10 @@ class Dns
if (array_key_exists($entry['type'], $required_entries) && array_key_exists(md5($entry['record']), $required_entries[$entry['type']])) {
unset($required_entries[$entry['type']][md5($entry['record'])]);
}
if (Settings::Get('system.dns_createcaaentry') == '1' && $entry['type'] == 'CAA' && strtolower(substr($entry['content'], 0, 7)) == '"v=caa1') {
// unset special CAA required-entry
unset($required_entries[$entry['type']][md5("@CAA@")]);
}
if (Settings::Get('spf.use_spf') == '1' && $entry['type'] == 'TXT' && $entry['record'] == '@' && strtolower(substr($entry['content'], 0, 7)) == '"v=spf1') {
// unset special spf required-entry
unset($required_entries[$entry['type']][md5("@SPF@")]);
@@ -296,9 +294,20 @@ class Dns
foreach ($required_entries as $type => $records) {
if ($type == 'CAA') {
foreach ($records as $record) {
$caa_entries = explode(PHP_EOL, $domain['caa']);
if ($record == '@CAA@') {
$caa_entries = explode(PHP_EOL, Settings::Get('caa.caa_entry'));
if ($domain['letsencrypt'] == 1) {
$le_entry = $domain['iswildcarddomain'] == '1' ? '0 issuewild "letsencrypt.org"' : '0 issue "letsencrypt.org"';
array_push($caa_entries, $le_entry);
}
foreach ($caa_entries as $entry) {
$zonerecords[] = new DnsEntry($record, 'CAA', self::encloseTXTContent($entry));
$zonerecords[] = new DnsEntry('@', 'CAA', self::encloseTXTContent($entry));
// additional required records by subdomain setting
if ($domain['wwwserveralias'] == '1') {
$zonerecords[] = new DnsEntry('www', 'CAA', self::encloseTXTContent($entry));
}
}
}
}
}

View File

@@ -1849,10 +1849,8 @@ $lng['serversettings']['leenabled']['description'] = "If activated, customers ar
$lng['domains']['ssl_redirect_temporarilydisabled'] = "<br>The SSL redirect is temporarily deactivated while a new Let's Encrypt certificate is generated. It will be activated again after the certificate was generated.";
// Added for CAA record support
$lng['admin']['caa']['title'] = 'Use CAA DNS records';
$lng['admin']['caa']['description'] = 'DNS Certification Authority Authorization (CAA) is an Internet security policy mechanism which allows domain name holders to indicate to certificate authorities whether they are authorized to issue digital certificates for a particular domain name. It does this by means of a new "CAA" Domain Name System (DNS) resource record.<br>The content of this field will be included into the DNS zone directly (each line results in a CAA record). An example for the use with Let\'s Encrypt would be:<br><code>0 issue "letsencrypt.org"</code><br>To enable Incident Reporting, you would need to add an <code>iodef</code> record. An example for sending such report to <code>me@example.com</code> would be:<br><code>0 iodef "mailto:me@example.com"</code><br><strong>Attention:</strong> The code won\'t be checked for any errors. If it contains errors, DNS server might not start again!';
$lng['customer']['caa']['title'] = 'Use CAA DNS records';
$lng['customer']['caa']['description'] = 'DNS Certification Authority Authorization (CAA) is an Internet security policy mechanism which allows domain name holders to indicate to certificate authorities whether they are authorized to issue digital certificates for a particular domain name. It does this by means of a new "CAA" Domain Name System (DNS) resource record.<br>The content of this field will be included into the DNS zone directly (each line results in a CAA record). An example for the use with Let\'s Encrypt would be:<br><code>0 issue "letsencrypt.org"</code><br>To enable Incident Reporting, you would need to add an <code>iodef</code> record. An example for sending such report to <code>me@example.com</code> would be:<br><code>0 iodef "mailto:me@example.com"</code><br><strong>Attention:</strong> The code won\'t be checked for any errors. If it contains errors, DNS server might not start again!';
$lng['serversettings']['caa_entry'] = 'Generate CAA DNS records<br>Automatically generates CAA records for SSL-enabled domains that are using Let\'s Encrypt';
$lng['serversettings']['caa_custom'] = 'DNS Certification Authority Authorization (CAA) is an Internet security policy mechanism which allows domain name holders to indicate to certificate authorities whether they are authorized to issue digital certificates for a particular domain name. It does this by means of a new "CAA" Domain Name System (DNS) resource record.<br>The content of this field will be included into the DNS zone directly (each line results in a CAA record). If Let\'s Encrypt is enabled for this domain, this entry will always be added automatically and does not need to be added manually:<br><code>0 issue "letsencrypt.org"</code> (If domain is a wildcard domain, issuewild will be used instead).<br>To enable Incident Reporting, you can add an <code>iodef</code> record. An example for sending such report to <code>me@example.com</code> would be:<br><code>0 iodef "mailto:me@example.com"</code><br><strong>Attention:</strong> The code won\'t be checked for any errors. If it contains errors, your CAA records might not work!';
// Autoupdate
$lng['admin']['autoupdate'] = 'Auto-Update';

View File

@@ -1501,10 +1501,8 @@ $lng['serversettings']['leenabled']['description'] = "Wenn dies aktiviert ist, k
$lng['domains']['ssl_redirect_temporarilydisabled'] = "<br>Die SSL-Umleitung ist, während ein neues Let's Encrypt - Zertifikat erstellt wird, temporär deaktiviert. Die Umleitung wird nach der Zertifikatserstellung wieder aktiviert.";
// Added for CAA record support
$lng['admin']['caa']['title'] = 'CAA DNS Einträge erstellen';
$lng['admin']['caa']['description'] = 'DNS Certification Authority Authorization (CAA) verwendet das Domain Name System, um dem Besitzer einer Domain die Möglichkeit zu bieten, gewisse Zertifizierungsstellen (CAs) dazu zu berechtigen, ein Zertifikat für die betroffene Domain auszustellen. CAA Records sollen verhindern, dass Zertifikate fälschlicherweise für eine Domain ausgestellt werden.<br>Der Inhalt dieses Feldes wird direkt in die DNS Zone übernommen (eine Zeile pro CAA Record). Ein Beispiel für Let\'s Encrypt wäre:<br><code>0 issue "letsencrypt.org"</code><br>Um Incident Reporting per Mail zu aktivieren, muss eine <code>iodef</code> Zeile angefügt werden. Ein Beispiel für einen Report an <code>me@example.com</code> wäre:<br><code>0 iodef "mailto:me@example.com"</code><br><strong>ACHTUNG:</strong> Der Code wird nicht auf Fehler geprüft. Etwaige Fehler werden also auch übernommen. Der DNS-Server könnte nicht mehr starten!';
$lng['customer']['caa']['title'] = 'CAA DNS Einträge erstellen';
$lng['customer']['caa']['description'] = 'DNS Certification Authority Authorization (CAA) verwendet das Domain Name System, um dem Besitzer einer Domain die Möglichkeit zu bieten, gewisse Zertifizierungsstellen (CAs) dazu zu berechtigen, ein Zertifikat für die betroffene Domain auszustellen. CAA Records sollen verhindern, dass Zertifikate fälschlicherweise für eine Domain ausgestellt werden.<br>Der Inhalt dieses Feldes wird direkt in die DNS Zone übernommen (eine Zeile pro CAA Record). Ein Beispiel für Let\'s Encrypt wäre:<br><code>0 issue "letsencrypt.org"</code><br>Um Incident Reporting per Mail zu aktivieren, muss eine <code>iodef</code> Zeile angefügt werden. Ein Beispiel für einen Report an <code>me@example.com</code> wäre:<br><code>0 iodef "mailto:me@example.com"</code><br><strong>ACHTUNG:</strong> Der Code wird nicht auf Fehler geprüft. Etwaige Fehler werden also auch übernommen. Der DNS-Server könnte nicht mehr starten!';
$lng['serversettings']['caa_entry']= 'CAA DNS Einträge generieren<br>Generiert CAA Einträge automatisch für alle Domains mit aktiviertem SSL und Let\'s Encrypt';
$lng['serversettings']['caa_custom']= 'DNS Certification Authority Authorization (CAA) verwendet das Domain Name System, um dem Besitzer einer Domain die Möglichkeit zu bieten, gewisse Zertifizierungsstellen (CAs) dazu zu berechtigen, ein Zertifikat für die betroffene Domain auszustellen. CAA Records sollen verhindern, dass Zertifikate fälschlicherweise für eine Domain ausgestellt werden.<br>Der Inhalt dieses Feldes wird direkt in die DNS Zone übernommen (eine Zeile pro CAA Record). Wenn Let\'s Encrypt für eine Domain aktiviert wurde und die obige Option aktiviert wurde, wird immer automatisch dieser Eintrag angefügt und muss nicht selber angegeben werden:<br><code>0 issue "letsencrypt.org"</code> (Wenn wildcard aktiviert ist, wird statdessen issuewild benutzt).<br>Um Incident Reporting per Mail zu aktivieren, muss eine <code>iodef</code> Zeile angefügt werden. Ein Beispiel für einen Report an <code>me@example.com</code> wäre:<br><code>0 iodef "mailto:me@example.com"</code><br><strong>ACHTUNG:</strong> Der Code wird nicht auf Fehler geprüft. Etwaige Fehler werden also auch übernommen. Die CAA finalen Einträge könnten daher falsch sein!';
// Autoupdate
$lng['admin']['autoupdate'] = 'Auto-Update';