exclude .onion domains from dkim feature

This commit is contained in:
danwin1210 committed 2026-10-17 19:07:04 +02:00
1 parent 04f3bdfdb0
commit 304a48b231
2 files changed
+31 -29

No files matched your search

+29 -27
View File
@@ -872,38 +872,40 @@ function send_edit_domain(): void
value="1"<?php echo $admin[ 'active' ] ? ' checked' : ''; ?>><?php echo htmlspecialchars(_('Active')); ?></label>
</div>
</div>
<?php if ( $_SESSION[ 'email_admin_superadmin' ] ) { ?>
<div class="row">
<div class="col"><?php echo htmlspecialchars(_('DKIM selector')); ?></div>
<div class="col"><?php echo htmlspecialchars( $admin[ 'dkim_selector' ] ); ?></div>
</div>
<?php
$public_key = get_rsa_dkim_public_key_base64( $admin[ 'dkim_key' ] );
if ( $public_key === null ) {
error_log( 'Invalid RSA DKIM key configured for ' . $admin[ 'domain' ] );
}
?>
<div class="row">
<div class="col"><?php echo htmlspecialchars(_('DKIM DNS TXT record')); ?></div>
<div class="col">
<?php echo htmlspecialchars( $admin[ 'dkim_selector' ] . '._domainkey.' . $admin[ 'domain' ] ); ?>
<textarea rows="4" readonly><?php echo htmlspecialchars( $public_key === null ? '' : 'v=DKIM1; k=rsa; p=' . $public_key ); ?></textarea>
</div>
</div>
<?php } ?>
<?php if(!str_ends_with( $admin[ 'domain' ], '.onion' )) { ?>
<?php if ( $_SESSION[ 'email_admin_superadmin' ] ) { ?>
<div class="row">
<div class="col"><?php echo htmlspecialchars(_('DKIM selector')); ?></div>
<div class="col"><?php echo htmlspecialchars( $admin[ 'dkim_selector' ] ); ?></div>
</div>
<?php
$public_key = get_rsa_dkim_public_key_base64( $admin[ 'dkim_key' ] );
if ( $public_key === null ) {
error_log( 'Invalid RSA DKIM key configured for ' . $admin[ 'domain' ] );
}
?>
<div class="row">
<div class="col"><?php echo htmlspecialchars(_('DKIM DNS TXT record')); ?></div>
<div class="col">
<?php echo htmlspecialchars( $admin[ 'dkim_selector' ] . '._domainkey.' . $admin[ 'domain' ] ); ?>
<textarea rows="4" readonly><?php echo htmlspecialchars( $public_key === null ? '' : 'v=DKIM1; k=rsa; p=' . $public_key ); ?></textarea>
</div>
</div>
<?php }
if ( $_SESSION[ 'email_admin_superadmin' ] ) { ?>
<div class="row">
<div class="col">
<button type="submit" name="action" value="confirm_regenerate_dkim_key"><?php echo htmlspecialchars(_('Regenerate DKIM key')); ?></button>
</div>
</div>
<?php }
} ?>
<div class="row">
<div class="col">
<button name="action" value="save_edit_domain" type="submit"><?php echo htmlspecialchars(_('Save changes')); ?></button>
</div>
</div>
<?php if ( $_SESSION[ 'email_admin_superadmin' ] ) { ?>
<div class="row">
<div class="col">
<button type="submit" name="action" value="confirm_regenerate_dkim_key"><?php echo htmlspecialchars(_('Regenerate DKIM key')); ?></button>
</div>
</div>
<?php } ?>
<div class="row">
<div class="row">
<div class="col">
<button type="submit" name="action" value="delete_domain"><?php echo htmlspecialchars(_('Delete domain')); ?></button>
</div>
+2 -2
View File
@@ -14,8 +14,8 @@ if ( ! in_array( $_SERVER[ 'REQUEST_METHOD' ], [ 'GET', 'HEAD' ], true ) || ! ha
$stmt = get_db_instance()->query( "SELECT domain, dkim_key, dkim_selector FROM domain WHERE active = 1 ORDER BY domain;" );
$map_entries = [];
while ( $domain = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
if(empty($domain['dkim_key'])) {
continue; // Skip domains without DKIM keys
if(empty($domain['dkim_key']) || str_ends_with($domain['domain'], '.onion')) {
continue; // Skip domains without DKIM keys or onion domains
}
$ascii_domain = idn_to_ascii( $domain[ 'domain' ], IDNA_NONTRANSITIONAL_TO_ASCII );
$key = get_rsa_dkim_private_key_base64_der( $domain[ 'dkim_key' ] );