Client-certificate login

Users can sign in to the web interface with a TLS client certificate instead of a password. It is off unless an administrator sets web.client_ca.

Turn it on

web {
  client_ca = "/etc/bongo/client-ca.pem"
}

client_ca is a PEM file with one or more CA certificates. Every certificate in it must be a CA. The key is a restart-class setting, and startup fails when the file is missing, unreadable or holds no CA certificate. The error names the key and the path, never the file contents.

Bongo must terminate TLS itself. web.client_ca is refused together with web.behind_tls_proxy or web.plain_http. Bongo never reads client-certificate headers from a proxy (X-SSL-Client-Cert and the like): there is no header path at all, so a proxy cannot assert a certificate.

With the key set, the web listener asks every browser for a client certificate and never requires one. Browsers offer only certificates issued by the CAs in the file. On macOS and Windows a browser that holds such a certificate may show a certificate picker when it opens the site; choosing none changes nothing. CalDAV and CardDAV clients on the same listener are asked too and may ignore it.

The request is not private. Every TLS client of the web listener, signed in or not, receives the distinguished names of the CAs in client_ca in the handshake’s CertificateRequest message, so anyone can read them with openssl s_client. Pick a CA whose name you do not mind exposing: a subject such as CN=Example Internal Staff CA, O=Example Ltd tells every visitor the organisation runs it. A dedicated CA with a neutral name gives nothing away.

The check is made by the application, not in the TLS handshake. An expired certificate, one from another CA or one without the client-authentication usage still completes the handshake and the user gets the normal password form. (Go’s VerifyClientCertIfGiven would abort the handshake instead and lock that browser out of the whole site.) ACME TLS-ALPN-01 validation is unaffected, and so is HTTP/2.

Register a certificate

  1. Open the site in a browser that holds your certificate and pick it when asked.
  2. Sign in with your password and open Settings, Security, Client certificates.
  3. The page names the certificate the browser presented. Enter your current password (and a 2FA code if you use 2FA) and choose Register this certificate.

Only the certificate presented on the current connection can be registered, not pasted text. The browser proves it holds the private key during the handshake; a pasted certificate would prove nothing and would let anyone attach somebody else’s certificate to their own account. Bongo stores the SHA-256 fingerprint of the certificate, its common name for display and its expiry date. At most five certificates can be registered per account. A certificate that does not chain to the configured CA, is expired or lacks the client-authentication usage is refused at registration.

Sign in

The login page shows a second form, Sign in with certificate. Enter your email address and press the button. It is explicit, never automatic, so logging out stays logged out.

The chain is verified on every attempt before the account is looked up, so an unknown address and an existing one take the same work and the response time does not show which addresses exist.

Sign-in succeeds only when the presented certificate chains to client_ca, is valid for client authentication, is within its validity period and its fingerprint is registered on that account. 2FA still applies. Every other case, including an unknown address, an unregistered or invalid certificate, a disabled account, a resource or shared inbox account, an account whose web feature is switched off and a directory account, shows the same page and status as a wrong password. Failures count against the same login limiter as password attempts.

Directory (LDAP) accounts cannot use certificates, neither to register nor to sign in: this path never asks the directory, so a user removed or disabled there could otherwise still get in. Directory users sign in with their directory password.

Remove a certificate and revocation

Removing a certificate needs your password (and 2FA code) and ends the web sessions on every other device, because a session does not record how it was opened. The device you removed it from stays signed in. Registering a certificate ends nothing.

Bongo does not check certificate revocation lists. To lock out a lost certificate, remove its registration, or disable the account, which blocks certificate sign-in too.

Every registered certificate of an account is removed, in the same profile write that ends its other sessions, when:

  • the user changes their password on the Security page (the page then says the certificates were removed);
  • an administrator resets the user’s password (the admin page says so next to the temporary password);
  • an administrator resets the user’s two-factor authentication, on the admin page or with bongo user reset-2fa (the admin page says so).

These actions answer a lost or compromised password or second factor, and whoever had it could have registered a certificate of their own, which would otherwise keep signing in after the reset. The user registers their certificates again afterwards. Turning 2FA off yourself on the Security page keeps them.

When client_ca is not set

The login form route and the register and remove routes answer 404, not 403, when client_ca is unset: the feature does not exist on that server, so the routes behave as if they were not registered, the same answer an older node gives. A 403 would say the feature exists and the caller lacks permission. With client_ca set, a directory account gets 403 on register and remove, because there the feature exists and that account may not use it.

Several nodes and upgrades

Registrations are plain profile writes and replicate with the profile. An older binary does not know web.client_ca and refuses the configuration, so add the key only after every node runs this version. An older node keeps the registered certificates when it rewrites a profile, but it has no certificate login: the route answers 404 and the page shows no button. Nothing diverges.

Logs carry the user id and the outcome (login: certificate accepted, login: client certificate registered, login: client certificate removed), never the certificate subject or content.

View this page's source on GitHub