1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-10-29 15:02:30 +00:00
Commit Graph

314 Commits

Author SHA1 Message Date
Alberto Bertogli b3a500d9e4 smtpsrv: Use SNI as hostname only if it matches one of our certs
Today, the client can give us any SNI, and still complete a valid
negotiation, which means it can be attacker-controlled (including having
problematic characters).

We use that SNI as our hostname in a variety of places, including
Received and Authentication-Results headers. This creates an
opportunity for an attacker to manipulate those headers.

To fix that problem, this patch only takes the SNI if it matches one of
our certs' hostnames. Otherwise we use the configured hostname (same as
if there was no SNI today).

Once Go 1.27 is our minimum supported version, we can simplify this
further by checking the SNI against ConnectionState.LocalCertificate.
2026-10-12 21:16:01 +01:00
Alberto Bertogli 9de93edf77 smtpsrv: Reject MAIL FROM/RCPT TO addresses with control characters
Today we rely on net/mail.ParseAddress to do most of the validation of
the addresses, and it is quite effective at it. But it does not reject
addresses with control characters, which could end up verbatim in
problematic places (e.g. logs).

Specifically the C1 characters, like U+009B (Control Sequence
Introducer) will pass through and could be problematic, since it is
interpreted by some terminals.

It also allows (quoted) parenthesis, which could confuse Received header
parsers. This is mainly harmless, but it can be confusing when
troubleshooting.

Today, we also reject addresses with more than one @, but as a
side-effect of domain validation.

To reduce the chances of problems later, this patch rejects addresses if
they contain control characters (which is a behaviour change), or more
than one @ (which is pre-existing, but now we fail in a more explicit
way).

It also escapes the addresses containing parenthesis in the Received
header, to make debugging info clearer, and keep the header structure
compliant.
2026-10-12 20:47:51 +01:00
Alberto Bertogli f3374e7923 smtpsrv: Always sanitize HELO/EHLO domain
Today we use the HELO/EHLO domain in a variety of places, which are
informational, but some have specific syntax (like the Received header).
Using the un-sanitized values can lead to some confusing and/or invalid
values. This is not very risky today, but it could be problematic in the
future if these strings are used in other contexts.

To prevent those problems, this patch sanitizes the HELO/EHLO domain
when receiving it.

Hooks used to receive the sanitized and raw variants; now, both are
sanitized (the raw one is kept for backwards compatibility).

If the sanitization leaves the string empty, we use the hard-coded
no-valid-characters.invalid as a placeholder, to make this situation
easier to identify when troubleshooting.
2026-10-12 20:20:02 +01:00
Alberto Bertogli 10aa1a55d0 dkim: Validate domain in s= and d= tags
We currently use the s= and d= tags as-is without any validation.

They are used to construct the DNS name to look up the key, which is
generally fine, but also the d= tag is used as-is in the
Authentication-Results header.

The latter can be used to inject malicious content, for example:

  d=example.com dkim=pass header.d=example.net

can result in the header including:

  header.d=example.com dkim=pass header.d=example.net

regardless of the validation status.

To fix that problem, this patch now validates the domain (using the same
normalization we use in other areas, like RCPT TO and MAIL FROM) on both
tags.

If any of the tags have invalid domains, we consider the signature
invalid as per RFC 6376 section 3.5.
2026-10-12 19:53:47 +01:00
Alberto Bertogli 5e827fe36f trace: Truncate long messages
Currently we trace everything we are given; sometimes in rare but valid
cases that can be multi-MiB strings. That gets logged and stays in
memory for tracing, which can blow up quite a lot and be a source of
problems and unexpected excessive resource usage.

To mitigate this and reduce the chances of issues, this patch truncates
very long messages to 8k utf8 characters. That's long enough to be
useful for debugging, without running the risk of causing problems on
extremely long messages.

We may adjust this issue in the future if this limit becomes a problem.
2026-10-12 19:29:40 +01:00
Alberto Bertogli 7a30982bf0 trace: Format messages only once, and only log them if needed
Today, trace.Printf and trace.Debugf format the message more than once:
at least once for logging, and once for tracing.

Some of that formatting can be expensive for large messages, causing CPU
and RAM spikes due to transient allocations. So this patch makes those
trace functions only format once, and avoid the logging calls if they're
below the logging level.
2026-10-12 16:13:40 +01:00
Alberto Bertogli b09ef96eab dkim: Limit size of RSA keys to 8192 bits
Operating on large RSA keys can be computationally expensive. Several
implementations (e.g. crypto/tls, OpenSSL, rspamd) limit their size
to prevent DoS via work amplification.

This patch introduces that limit in our dkim library, set to 8192 bits.

That's the same limit used by other implementations, like crypto/tls
(which limits size of RSA keys in certificates) and rspamd (specifically
for DKIM). It is also in line with the most recent DMARC.org report of
key sizes in the wild (https://dmarc.org/stats/dkim/), where 8192 is
already rare, and the largest one found.
2026-10-12 15:36:02 +01:00
Alberto Bertogli 71af456be7 dkim: Consider only 3 TXT records when fetching keys
Today, when looking up DKIM keys via DNS, we go through all the TXT
records that are published. This is already more lenient than what's
allowed by many implementations (as documented in the code).

Potentially, someone could craft a domain with a lot of TXT records to
make us waste time processing those keys.

To help reduce that possibility, this patch limits the lookup to 3
records. This is still more than normal and may be limited further to 1
in the future.
2026-10-12 15:29:53 +01:00
Alberto Bertogli 6b64c9ccba smtpsrv: Set a limit on concurrent SMTP connections
If chasquid runs out of file descriptors, that can cause problems
accepting connections, writing to the queue, and even reloading configs.
Some of those errors are fatal, as they should not happen under normal
conditions.

Since a remote client can open a lot of connections, this can end up
consuming all file descriptors, and resulting in a denial of service. To
reduce the impact of that kind of event, this patch makes chasquid limit
the number of concurrent SMTP connections to half the maximum number of
file descriptors.

Connections over that limit will get closed immediately. The server
will log (rate-limited) when such event happens, and new metrics
make these events visible through monitoring too.

This approach complements the previous patch, which made the server
retry Accept errors, to reduce the impact of connection overloads.

This mainly affects deployments with low file descriptor limits; most
modern deployments have very high limits by default, so they are
unlikely to experience this problem in the first place.

Users who have to be very defensive can deploy OS-level safeguards (such
as firewall rules to limit number of connections, etc.) which are more
effective and tunable.

Thanks to John JEAN <john@wargan.com> for finding and reporting this
problem. The detailed report can be found in
https://johnjean.io/advisories/chasquid-unauthenticated-remote-dos/.
2026-10-09 23:32:26 +01:00
Alberto Bertogli 6dc05d2aad smtpsrv: Do not exit on Accept errors
Today, if Accept returns an error, we exit the daemon. Unfortunately
this is not that difficult to trigger: a remote client can open a large
number of connections to reach the limit of file descriptors.

This patch makes the server retry instead, with an exponential backoff
(up to 1s).

This is a compromise to improve handling of such scenarios without
introducing a lot of complexity.

The problem can still be triggered but this change makes the daemon more
resilient to it (and it will be improved further in follow-up patches).
Users who have to be very defensive can deploy OS-level safeguards (such
as firewall rules to limit number of connections, etc.) which are more
effective and tunable.

Thanks to John JEAN <john@wargan.com> for finding and reporting this
problem. The detailed report can be found in
https://johnjean.io/advisories/chasquid-unauthenticated-remote-dos/.
2026-10-09 23:02:53 +01:00
Alberto Bertogli 4b0b31a749 dkim: Add fuzzing tests
This patch adds two fuzzing tests to the dkim package:

1) Fuzz the sign-verify cycle, checking we can verify any message we
   sign.
2) Fuzz the message we verify, returning valid keys for any domain so it
   gets past the key fetching, and exercises a substantial part of the
   verification process.

The first test already found two issues, which were fixed in the
previous patches.
2026-10-09 21:34:17 +01:00
Alberto Bertogli b3b1f39d85 dkim: Use same header name folding for signing and verifying
Today, we fold header names with strings.EqualFold when signing, but
strings.ToLower when verifying.

This should be harmless for valid messages (that have only ASCII
characters in the header names), but if one contains an (invalid) header
with a non-ASCII character, we could fail to verify the message we sign.

The inconsistency would only happen if a header has a non-ASCII
character that strings.EqualFold and strings.ToLower handle differently
(like "ſubject", with U+017F).

To make signing and verifying consistent, this patch makes signing use
strings.ToLower.

This bug was found by fuzzing the sign-verify cycle, which will be added
in a later patch.
2026-10-09 21:34:17 +01:00
Alberto Bertogli 3b0836f811 dkim: When signing, process repeated headers from bottom to top
When signing repeated headers, today we hash each instance of a header
from top to bottom.

However, RFC 6376 section 5.4.2 is clear they should be processed bottom
to top, and this is also what our verifier (correctly) expects.

The bug causes our signatures to be (wrongly) invalid for messages that
have repeated signed headers with different values.

Note that repeated headers that are not signed (e.g. Received:) are not
problematic. This only affects headers we sign, like To:, From:,
Subject:.

This patch fixes the problem by adjusting the order in which Sign
processes repeated headers.

This bug was found by fuzzing the sign-verify cycle, which will be added
in a later patch.
2026-10-09 21:34:17 +01:00
Alberto Bertogli 49030cb9c8 dkim: Messages without a blank line should have an empty body
Today, if a message does not have a blank line (which separates headers
and body), we also include all lines except the first as the body (even
the ones parsed as headers). This is incorrect.

This patch fixes the code so that in those messages, all the lines are
headers, and the body is empty.

Note that since SMTP messages have to end with a new line, that final
line will act as the separator if there is no body. So this bug only
impacts signing/verification of files on disk via chasquid-util.
2026-10-09 21:34:17 +01:00
Alberto Bertogli ce236e91bc dkim: Fix quadratic behaviour when parsing headers
When parsing a header that has a continuation line, today we append that
line to it, which copies the whole header each time.

On normal messages this is negligible, but a header with a very large
number of continuation lines would cause a DoS through work
amplification.

This patch fixes the problem by making header continuation handling
linear: we now accumulate the header lines in a list, and then join them
only once.

Thanks to John JEAN <john@wargan.com> who reported a similar issue
(fixed in a previous patch), which led to finding this bug.
2026-10-09 21:34:10 +01:00
Alberto Bertogli b153955d5d dkim: Fix work amplification on h= tag processing
When verifying emails, for each entry in the h= tag, we would scan all
headers, leading to quadratic behaviour.

Similarly, when signing, for each instance of a signed header we would
scan all headers.

This could lead to unauthenticated DoS via work amplification.

This patch fixes the problem by going through the headers only once, so
behaviour is now linear, and also limiting the size of the h= tag for
defense in depth.

The limit is in line with what other implementations use, so it should
not cause any interoperability problems.

Thanks to John JEAN <john@wargan.com> for finding and reporting this
problem. The detailed report can be found in
https://johnjean.io/advisories/chasquid-unauthenticated-remote-dos/.
2026-10-09 21:34:10 +01:00
Alberto Bertogli 5c4193a8b6 dkim: l=0 means none of the body is signed
Today, we treat l=0 to mean the whole body is signed. However, RFC 6376
is clear that means _none_ of the body is signed.

This patch fixes that behaviour to match the RFC.

Cross-checking other implementations for potential compatibility issues,
OpenDKIM and Exim both treat l=0 the same way this patch does.

In practice, l=0 is extremely rare, and that's why this incorrect
behaviour persisted unnoticed for so long.

Note this incorrect behaviour would cause valid signatures to fail to
verify, but never allow invalid signatures to pass.
2026-10-09 21:34:10 +01:00
Alberto Bertogli 2612c8bfa1 dkim: Fail verification if l= is too large
Currently, if the value of the l= tag is larger than the body, that
causes an out-of-bound access and the server crashes.

The RFC is clear that the value should be <= the size of the
canonicalized body.

This patch fixes the problem by validating the length appropriately, and
returning a permanent failure if it's invalid.

Thanks to John JEAN <john@wargan.com> who reported a similar issue
(fixed in a previous patch), which led to finding this bug.
2026-10-09 21:32:22 +01:00
Alberto Bertogli 46c0644363 queue: Fix inverted logic in mustIDNAToASCII
In mustIDNAToASCII, we accidentally return the unconverted domain on
success, and the failed conversion on error.

This affects the sender rewriting when forwarding, and can only be
triggered via aliases in local IDN domains.

This patch fixes the problem by adjusting the logic, and adds tests to
prevent future regressions.
2026-10-09 00:02:13 +01:00
Alberto Bertogli 61792e3bb4 Reject invalid characters in domains
Domains in addresses had very lax validation, which allowed them to
include characters like "/".

That could be exploited to trigger a daemon panic: a MAIL FROM
"x@evil/foo" could be accepted and, on failed delivery, a DSN queued.
Attempting to deliver the DSN would cause an MTA-STS cache lookup, which
would panic because the domain includes a "/" and crash the server.
Because the DSN would be queued, the server would crash again on
restarts, and only self-recover after give_up_send_after (20h by
default).

To fix this, we now explicitly validate the domain when normalizing it,
make MTA-STS cache not panic on invalid domains, and also make the SMTP
courier fail permanently on invalid domains.

Thanks to John JEAN <john@wargan.com> for finding and reporting this
problem. The detailed report can be found in
https://johnjean.io/advisories/chasquid-unauthenticated-remote-dos/.
2026-10-09 00:00:12 +01:00
Alberto Bertogli b23047aa83 monitoring: Use method-based routing and CSRF for http requests
The monitoring http server is mostly read-only but shows sensitive data,
and also has one mutating endpoint, /exit.

This patch updates the routing to use method-based routing, and also
wraps it on CSRF to reject cross-origin requests from browsers.

Note that does not affect direct POST /exit requests via tools like
curl or wget, which continue to work just like today. This is exercised
in the (unchanged) integration tests.
2026-10-04 19:02:05 +01:00
Alberto Bertogli 5131fdacb4 tlsconst: Deprecate in favour of stdlib's tls
The tlsconst internal package was created to provide human-readable
names for TLS versions and ciphers, from the IANA registry.

These days, that functionality is provided by stdlib's tls package, so
the internal package is no longer needed, and this patch removes it.

The only observable change is that the descriptive version in the
Received header now says "TLS 1.3" instead of "TLS-1.3", but it's just
as standard-compliant since that is in a free-form text section.
2026-10-04 18:35:40 +01:00
Alberto Bertogli d74e6e3d2b courier: Improve delivery error messages
Delivery errors can be visible to the end-user via DSN responses, and
some of them are not very clear, or are missing useful debugging
information (such as the MX).

This patch improves the messages by including the MX where appropriate,
having explicit errors for cases where no servers are found/allowed, and
using less technical language for the common explanations.

There are no changes to the behaviour on errors, this change only
affects the messages.
2026-10-03 11:36:19 +01:00
Alberto Bertogli bfb9694f0c Wrap errors with %w when returning them
Many places where we return errors don't use the %w wrapping, because
they predate that functionality.

This patch changes those to use %w, so callers can inspect the
underlying errors with errors.Is and errors.As if needed in the future.

The text of the errors does not change, and no existing callers inspect
these errors, so there are no behaviour changes.
2026-10-03 11:03:49 +01:00
Alberto Bertogli 8b19760f4e test: Use modern testing features instead of custom helpers
Many of our tests rely on helpers that predate features which are now
available in the standard library.

This patch replaces them with the standard equivalents:

- MustTempDir/RemoveIfOk -> t.ArtifactDir() or t.TempDir() (depending on
  whether it is useful to keep the data on request).
- GetFreePort + waitForServer -> opening the listeners before starting
  the servers. To support this, localrpc.Server gains a Serve method. We
  may re-introduce these in the future if more use cases appear.
- WaitFor and real-time timing checks -> testing/synctest.
- context.Background() -> t.Context().
- Benchmark b.N loops -> b.Loop().
- reflect.DeepEqual -> cmp.Diff, and proto.Equal for protobufs.
2026-10-03 10:34:35 +01:00
Alberto Bertogli 8d763f450d Apply more mechanical simplifications using recent Go features
This is a follow-up on the `go fix` run in commit
0210c5fd92.

That commit recorded the automated updates.

This one applies further simplifications that are mechanical and do not
involve logic changes, but are outside of what `go fix` did.

It also removes some now-obsolete comments and statements.
2026-10-03 09:31:15 +01:00
Alberto Bertogli 0210c5fd92 Apply go fix to simplify using modern features
This patch contains the result of running `go fix ./...`, which applies
simplifications that make use of modern language features.

There are no logic or behaviour changes.
2026-10-02 18:34:25 +01:00
ThinkChaos f69fdc1b1a dovecot: auto-detect sockets in /run/dovecot2
NixOS uses this path, and it seems generic enough to be worth adding
here.

The `/var/run` paths should probably also be updated to `/run`, but I'm
not going to risk breaking anything :)

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Adjusted comments.
2026-09-27 20:40:50 +01:00
Alberto Bertogli ab2a6e7eb3 test: Update expected strings to Go 1.25.11/1.26.4
In Go 1.25.11/1.26.4, net/textproto error formatting was changed, and
now the message is quoted. This is to protect from general string
injections.

See https://go-review.googlesource.com/c/go/+/778182 and
ec1c380418ec6a0da28d4519872e2b81ba9152ba.

After this change, the error strings from net/textproto (and net/smtp
which uses it) now include quotes.

For chasquid, the only user-observable change in the server is that the
errors included in the DSN messages are now quoted, which should not be
a problem.

However, some of the tests which validate error strings need to be
adjusted.

The patch also updates go.mod to set the Go version to match this new
minimum.
2026-06-07 12:08:29 +01:00
Alberto Bertogli 953d380424 make: Auto-format Python files, and update existing
This patch adds extends `make fmt` to auto-format Python files using
`black`, and also runs it on the existing files.
2026-04-06 19:31:58 +01:00
Alberto Bertogli e78d5043e3 maillog: Remove unnecessary newlines
This patch removes the unnecessary newlines in the maillog printf calls.

Note that the library will trim them anyway, so this is only for code
readability, but the logs should be unchanged.
2026-04-06 19:27:56 +01:00
xrstf 013af62116 maillog: Fix empty lines in the authentication log entries
In maillog.Auth, we currently have a newline in the log entry args.

The blitiri.com.ar/go/log package handles trailing newlines, but only in
the format parameter, not in the args.

Because of this, the authentication log entries in the maillog currently
end with an extra newline.

This patch fixes the problem by removing the unnecessary newline from
the message.

https://github.com/albertito/chasquid/pull/82

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Adjusted commit message.
2026-04-06 19:14:59 +01:00
Alberto Bertogli 1a4c672ac3 expvarom: Remove empty newlines and comments to conform to stricter parsing
The openmetrics format doesn't support empty newlines or miscellaneous
comments, and the Prometheus parser has become more strict over time,
which is now causing scraping errors.

This patch fixes those issues by adjusting to the stricter openmetrics
format.

Thanks to Jakub Ječmínek for reporting this issue!
2026-02-02 19:33:43 +00:00
Alberto Bertogli 1a014be277 internal/dkim: Apply gofmt -s
A run of `gofmt -s` found two instances where a struct definition could
be simplified. This patch applies those suggestions.
2025-10-24 12:43:51 +01:00
Alberto Bertogli 5c2566c9b1 Fix non-constant format string in calls to Printf-like functions
In a few places, we call Printf-like functions, but for the format we
use either non-format messages (which is not tidy, but okay), or
variable messages (which can be problematic if they contain %-format
directives).

The patch fixes the calls by either moving to Print-like functions, or
using `Printf("%s", message)` instead.

These were found by a combination of `go vet` (which complains about
"non-constant format string in call"), and manual inspection.
2025-10-24 12:34:58 +01:00
Alberto Bertogli 3776186288 protobuf: Regenerate with protoc-gen-go v1.36.10
Regenerate the protobuf auto-generated files using an updated version of
protoc-gen-go.
2025-10-24 12:26:16 +01:00
Alberto Bertogli f7e0e9fe65 Minor cleanups for staticcheck issues
staticcheck found a couple of minor code cleanup improvements, like
unused variables or an out-of-order defer, mostly in tests.

This patch fixes those problems by making the necessary adjustments.

They're all fairly small, and should not change the logic in any
significant way.
2025-10-24 12:15:36 +01:00
Alberto Bertogli 08273ea901 queue: Sync the files written on Put
When we put something in the queue and respond "250 ok" to the client,
that is taken as accepting the email.

As part of putting something in the queue, we write it to disk, but
today we don't do an fsync on that file.

That leaves a gap where a badly timed crash on some systems could lead
to the file being empty, causing us to lose an email that we accepted.

To elliminate (or drastically reduce on some filesystems) the chances of
that situation, we call fsync on the file that gets written when we put
something in the queue.

Thanks to nolanl@github for reporting this in
https://github.com/albertito/chasquid/issues/78.
2025-10-18 12:10:24 +01:00
Alberto Bertogli 45bc70ee33 smtpsrv: Fix "Received" header format when including the IP address
When constructing the "Received" header, in some cases we want to
include the remote IP address in addition to the EHLO domain.

The way we did that is not fully compliant with RFC 5321 (section 4.4),
and this has the potential to confuse some tools that parse the header.

This patch fixes this problem by adjusting the order of the two pieces
of data, which makes it comply with the RFC.

Before:

  Received: from [1.2.3.4] (ehlo.domain.example.com)

After:

  Received: from ehlo.domain.example.com ([1.2.3.4])

Thanks to nolanl@github for reporting this problem in
https://github.com/albertito/chasquid/issues/76.
2025-10-02 10:45:26 +01:00
ThinkChaos eeb2deb7f6 courier: Don't hardcode path to sleep binary in the tests
On NixOS, `/bin` is basically empty and this causes the courier tests
(which invoke `/bin/sleep`) to fail.

This patch fixes the tests by removing the hardcoded path.

https://github.com/albertito/chasquid/pull/73

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Adjusted commit message.
2025-08-13 23:10:16 +01:00
Alberto Bertogli 24c2c4f5fd Make the max queue size and give up time configurable
Today, the maximum number of items in the queue, as well as how long we
keep attempting to send each item, is hard-coded and not changed by end
users.

While they are totally adequate for chasquid's main use cases, it can
still be useful for some users to change them.

So this patch adds two new configuration options for those settings.
They're marked experimental for now, so we can adjust them if needed
after they get more exposure.

Thanks to Lewis Ross-Jones <lewis_r_j@hotmail.com> for suggesting this
improvement, and help with testing it.
2025-06-07 11:00:00 +01:00
Alberto Bertogli 9999a69086 aliases: Implement "via" aliases
This patch implements "via" aliases, which let us explicitly select a
server to use for delivery.

This feature is useful in different scenarios, such as a secondary MX
server that forwards all incoming email to a primary.

For now, it is experimental and the syntax and semantics are subject to
change.
2025-04-12 23:23:21 +01:00
Alberto Bertogli 1cf24ba94a Auto-format the Python scripts
We have a few Python scripts which over the years ended up with a
variety of formatting.

This patch auto-formats them using `black -l 79` to make them more
uniform, and easier to read and write.
2025-04-11 14:17:17 +01:00
Alberto Bertogli 9524d307eb aliases: Add more tests for multiple suffix separators
This patch adds more tests for situations involving multiple suffix
separators.
2025-04-06 14:04:53 +01:00
Alberto Bertogli 964a2a8f75 aliases: Introduce Recipient{} helper functions in the tests
In the tests, we create a lot of Recipient{}s, and that ends up being
very verbose and sometimes cumbersome.

Also, if we ever want to extend it, it would result in a lot of
unnecessary refactoring.

So this patch replaces the Recipient{} instantiations with helper
functions, to help readability and extendability.

This only affects the tests, and there are no changes to them either, it
is purely a refactor.
2025-04-06 14:04:53 +01:00
Alberto Bertogli 0e29fe4ad8 aliases: Return error on invalid lines
Today, aliases parsing is too lax, silently ignoring most kinds of invalid
lines.

That behaviour can cause a lot of confusion when users think the aliases
are being parsed, and also cause problems when extending the syntax.

This patch fixes that problem by making aliases parsing return errors on
the invalid lines.

Unfortunately this will cause some previously-accepted files to now be
rejected, but it should be quite visible.
2025-04-06 14:04:53 +01:00
Alberto Bertogli 2ee64deec0 aliases: Support '*' as the destination user
This patch implements support for aliases that contain '*' as the
destination user.

In that case, we replace it with the original user.

For example, `*: *@pond` will redirect `lilly@domain` to `lilly@pond`.

This is experimental for now, and marked as such in the documentation.
The semantics can be subtle, so we may need to adjust them later.
2025-04-06 14:04:53 +01:00
Alberto Bertogli 8e4d31c74c Fix minor typos found by codespell
This patch fixes some minor typos in comments and strings found by
codespell.

While at it, also expand some variable names that were not typos, but
caused false positives, and end up being more readable anyway.
2025-04-06 14:02:56 +01:00
Alberto Bertogli e5e7256d3e smtpsrv: Disable TLS session tickets to work around Microsoft problems
Microsoft SMTP servers have a bug that prevents them from successfully
establishing a TLS connection against modern Go TLS servers, and some
OpenSSL versions. It also doesn't fall back to plain-text, so this has
been causing deliverablity issues.

The problem started by the end of 2024 and it's still not fixed.

Unfortunately, because they're quite a big provider and are not fixing
their problem, it is worth to do a server-side workaround.

This patch implements that workaround: it disables TLS session tickets.

There is no security impact for doing so, and there is a small
performance penalty which is likely to be insignificant for chasquid's
main use cases.

This workaround should be removed once Microsoft fixes their problem.

We are going to make a 1.15.1 release for this, which this patch also
documents.

Thanks to Michael (l6d-dev@github) for reporting this issue and
suggesting this workaround!

See https://github.com/albertito/chasquid/issues/64 and
https://github.com/golang/go/issues/70232 for more details.
2025-03-31 09:19:45 +01:00
Alberto Bertogli 45580dae46 Update to math/rand/v2
This commit updates the uses of math/rand to math/rand/v2, which was
released in Go 1.22 (2024-02).

The new package is generally safer, see https://go.dev/blog/randv2 for
the details.

There are no user-visible changes, it is only adjusting the name of
functions, simplify some code thanks to v2 having a better API, etc.
2025-02-16 20:18:16 +00:00