mirror of
https://github.com/mjl-/mox.git
synced 2025-07-19 01:26:36 +03:00
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.
This commit is contained in:
60
doc.go
60
doc.go
@ -69,6 +69,11 @@ any parameters. Followed by the help and usage information for each command.
|
||||
mox config address rm address
|
||||
mox config domain add domain account [localpart]
|
||||
mox config domain rm domain
|
||||
mox config tlspubkey list [account]
|
||||
mox config tlspubkey get fingerprint
|
||||
mox config tlspubkey add address [name] < cert.pem
|
||||
mox config tlspubkey rm fingerprint
|
||||
mox config tlspubkey gen stem
|
||||
mox config alias list domain
|
||||
mox config alias print alias
|
||||
mox config alias add alias@domain rcpt1@domain ...
|
||||
@ -994,6 +999,61 @@ rejected.
|
||||
|
||||
usage: mox config domain rm domain
|
||||
|
||||
# mox config tlspubkey list
|
||||
|
||||
List TLS public keys for TLS client certificate authentication.
|
||||
|
||||
If account is absent, the TLS public keys for all accounts are listed.
|
||||
|
||||
usage: mox config tlspubkey list [account]
|
||||
|
||||
# mox config tlspubkey get
|
||||
|
||||
Get a TLS public key for a fingerprint.
|
||||
|
||||
Prints the type, name, account and address for the key, and the certificate in
|
||||
PEM format.
|
||||
|
||||
usage: mox config tlspubkey get fingerprint
|
||||
|
||||
# mox config tlspubkey add
|
||||
|
||||
Add a TLS public key to the account of the given address.
|
||||
|
||||
The public key is read from the certificate.
|
||||
|
||||
The optional name is a human-readable descriptive name of the key. If absent,
|
||||
the CommonName from the certificate is used.
|
||||
|
||||
usage: mox config tlspubkey add address [name] < cert.pem
|
||||
-no-imap-preauth
|
||||
Don't automatically switch new IMAP connections authenticated with this key to "authenticated" state after the TLS handshake. For working around clients that ignore the untagged IMAP PREAUTH response and try to authenticate while already authenticated.
|
||||
|
||||
# mox config tlspubkey rm
|
||||
|
||||
Remove TLS public key for fingerprint.
|
||||
|
||||
usage: mox config tlspubkey rm fingerprint
|
||||
|
||||
# mox config tlspubkey gen
|
||||
|
||||
Generate an ed25519 private key and minimal certificate for use a TLS public key and write to files starting with stem.
|
||||
|
||||
The private key is written to $stem.$timestamp.ed25519privatekey.pkcs8.pem.
|
||||
The certificate is written to $stem.$timestamp.certificate.pem.
|
||||
The private key and certificate are also written to
|
||||
$stem.$timestamp.ed25519privatekey-certificate.pem.
|
||||
|
||||
The certificate can be added to an account with "mox config account tlspubkey add".
|
||||
|
||||
The combined file can be used with "mox sendmail".
|
||||
|
||||
The private key is also written to standard error in raw-url-base64-encoded
|
||||
form, also for use with "mox sendmail". The fingerprint is written to standard
|
||||
error too, for reference.
|
||||
|
||||
usage: mox config tlspubkey gen stem
|
||||
|
||||
# mox config alias list
|
||||
|
||||
List aliases for domain.
|
||||
|
Reference in New Issue
Block a user