Skip to content

Commit 1b23b48

Browse files
idkidk000adminadmin
andauthored
feat: Update POSTFIX_TLS_REGEX to also handle stalwart (#23)
* update POSTFIX_TLS_REGEX to also handle stalwart * also match the closing paren and update the readme --------- Co-authored-by: adminadmin <[email protected]>
1 parent 62e945f commit 1b23b48

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This plugin parses the "Received" header for the last hop and checks if TLS was
55
receiving MTA.
66

77
In Postfix this can be enabled by
8-
setting [`smtpd_tls_received_header = yes`](https://www.postfix.org/postconf.5.html#smtpd_tls_received_header). Sendmail
8+
setting [`smtpd_tls_received_header = yes`](https://www.postfix.org/postconf.5.html#smtpd_tls_received_header). Sendmail and Stalwart
99
should work out of the box. Other MTAs have not been explicitly tested.
1010

1111
Note that while this talks about "encryption", this does not imply security. An encrypted mail may still be insecure,

test/TlsIconTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ final class TlsIconTest extends TestCase
3030
/** @var string */
3131
private $strSendmailCryptedTlsv12WithCipherVerify = '<img class="lock_icon" src="plugins/tls_icon/lock.svg" title="TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK" />';
3232

33+
/** @var string */
34+
private $strStalwartCryptedTlsv13WithCipher = '<img class="lock_icon" src="plugins/tls_icon/lock.svg" title="TLSv1.3 with cipher TLS13_AES_256_GCM_SHA384" />';
3335

3436
public function testInstance()
3537
{
@@ -379,4 +381,40 @@ public function testSendmailTLS13MultipleRecipients()
379381
]
380382
], $headersProcessed);
381383
}
384+
385+
public function testStalwartTls()
386+
{
387+
$o = new tls_icon();
388+
$headersProcessed = $o->message_headers([
389+
'output' => [
390+
'subject' => [
391+
'value' => 'Sent to you',
392+
],
393+
],
394+
'headers' => (object) [
395+
'others' => [
396+
'received' => 'from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174] (AS15169 Google LLC, US))
397+
(using TLSv1.3 with cipher TLS13_AES_256_GCM_SHA384)
398+
by mail.example.org (Stalwart SMTP) with ESMTPS id 36DAF29F3A02098;
399+
Mon, 16 Jun 2025 13:33:03 +0000',
400+
]
401+
]
402+
]);
403+
$this->assertEquals([
404+
'output' => [
405+
'subject' => [
406+
'value' => 'Sent to you' . $this->strStalwartCryptedTlsv13WithCipher,
407+
'html' => 1,
408+
],
409+
],
410+
'headers' => (object) [
411+
'others' => [
412+
'received' => 'from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174] (AS15169 Google LLC, US))
413+
(using TLSv1.3 with cipher TLS13_AES_256_GCM_SHA384)
414+
by mail.example.org (Stalwart SMTP) with ESMTPS id 36DAF29F3A02098;
415+
Mon, 16 Jun 2025 13:33:03 +0000',
416+
]
417+
]
418+
], $headersProcessed);
419+
}
382420
}

tls_icon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class tls_icon extends rcube_plugin
44
{
5-
const POSTFIX_TLS_REGEX = "/\(using (TLS.*)\) \(/im";
5+
const POSTFIX_TLS_REGEX = "/\(using (TLS[^()]+(?:\([^)]+\))?)\)/im";
66
const POSTFIX_LOCAL_REGEX = "/\([a-zA-Z]*, from userid [0-9]*\)/im";
77
const SENDMAIL_TLS_REGEX = "/\(version=(TLS.*)\)(\s+for|;)/im";
88

0 commit comments

Comments
 (0)