mox/smtpserver
Mechiel Lukkien 8804d6b60e
implement tls client certificate authentication
the imap & smtp servers now allow logging in with tls client authentication and
the "external" sasl authentication mechanism. email clients like thunderbird,
fairemail, k9, macos mail implement it. this seems to be the most secure among
the authentication mechanism commonly implemented by clients. a useful property
is that an account can have a separate tls public key for each device/email
client.  with tls client cert auth, authentication is also bound to the tls
connection. a mitm cannot pass the credentials on to another tls connection,
similar to scram-*-plus. though part of scram-*-plus is that clients verify
that the server knows the client credentials.

for tls client auth with imap, we send a "preauth" untagged message by default.
that puts the connection in authenticated state. given the imap connection
state machine, further authentication commands are not allowed. some clients
don't recognize the preauth message, and try to authenticate anyway, which
fails. a tls public key has a config option to disable preauth, keeping new
connections in unauthenticated state, to work with such email clients.

for smtp (submission), we don't require an explicit auth command.

both for imap and smtp, we allow a client to authenticate with another
mechanism than "external". in that case, credentials are verified, and have to
be for the same account as the tls client auth, but the adress can be another
one than the login address configured with the tls public key.

only the public key is used to identify the account that is authenticating. we
ignore the rest of the certificate. expiration dates, names, constraints, etc
are not verified. no certificate authorities are involved.

users can upload their own (minimal) certificate. the account web interface
shows openssl commands you can run to generate a private key, minimal cert, and
a p12 file (the format that email clients seem to like...) containing both
private key and certificate.

the imapclient & smtpclient packages can now also use tls client auth. and so
does "mox sendmail", either with a pem file with private key and certificate,
or with just an ed25519 private key.

there are new subcommands "mox config tlspubkey ..." for
adding/removing/listing tls public keys from the cli, by the admin.
2024-12-06 10:08:17 +01:00
..
alias_test.go when opening an account by email address, such as during login attempts, and address is an alias, fail with proper error "no such credentials" instead of with error "no such account", which printing a stack trace 2024-11-10 23:20:17 +01:00
alignment.go switch to slog.Logger for logging, for easier reuse of packages by external software 2023-12-14 13:45:52 +01:00
analyze.go fix embarrasing bug in checking if string is ascii 2024-10-04 20:05:28 +02:00
dnsbl.go switch to slog.Logger for logging, for easier reuse of packages by external software 2023-12-14 13:45:52 +01:00
dsn.go ensure senderaccount is always set for messages in queue 2024-04-28 11:03:47 +02:00
error.go for imap/smtp syntax errors, only echo the remaining buffer if the connection is authenticated 2023-03-10 11:32:34 +01:00
fuzz_test.go in more tests, after closing accounts, check the last reference is indeed gone 2024-04-16 17:33:54 +02:00
limitwriter.go mox! 2023-01-30 14:27:06 +01:00
mx.go implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery 2023-10-10 12:09:35 +02:00
parse.go add parser of Authentication-Results, and fix bugs it found in our generated headers 2024-03-13 17:35:53 +01:00
parse_test.go mox! 2023-01-30 14:27:06 +01:00
rejects.go replace packages slog and slices from golang.org/x/exp with stdlib 2024-02-08 14:49:01 +01:00
reputation.go add more details to x-mox-reason message header added during delivery, for understanding why a message is accepted/rejected 2024-10-04 16:01:30 +02:00
reputation_test.go add more details to x-mox-reason message header added during delivery, for understanding why a message is accepted/rejected 2024-10-04 16:01:30 +02:00
server.go implement tls client certificate authentication 2024-12-06 10:08:17 +01:00
server_test.go implement tls client certificate authentication 2024-12-06 10:08:17 +01:00