You are asked to make a production database refuse every unencrypted client connection. How do you get there without an outage, and what keeps it working afterwards?
answer
- inventory plaintext sessions before flipping
- enable, migrate, prove zero, enforce
- forgotten clients: replicas, backups, CI, BI
- trust the new CA before switching the server
- expiry alerting is now availability work
basics
~20 sMeasure first: list live connections and which are unencrypted. Enable TLS server-side while still accepting plaintext, migrate every client to verified TLS with the CA bundle shipped, watch the plaintext count reach zero, then flip the server rule to reject non-TLS. Afterwards, automate renewal and alert on certificate expiry.
solid answer
~50 sTreat it as a migration, not a config flip. 1. **Inventory.** Use the server's per-connection view of encryption status plus connection logs to enumerate who still connects in cleartext -- and remember the non-obvious clients: replicas, backup and dump tools, migration runners, BI tools, admin CLIs, health checks. 2. **Enable, don't enforce.** Install the server certificate and accept both encrypted and plaintext connections so nothing breaks. 3. **Migrate clients** to verify-full, shipping the CA bundle with each deployment and dialling the certified hostname. Do this per service, verifying each one flips to encrypted. 4. **Prove zero.** Alert on any plaintext session; only when the count has been zero for a stable window do you change the server-side connection rules to require TLS (and, where supported, per-role requirements). 5. **Keep it alive.** Automated renewal, expiry alerting well before the deadline, the new CA trusted by clients *before* the server starts using it, and a rehearsed rollback.
go deeper
Say that you must enable TLS and move clients over before rejecting plaintext, and that certificates expire.
Add the measurement step and name the easily forgotten clients; know that verification mode matters as much as enforcement.
Run it as a staged migration with evidence-based cutover, scoped exceptions, rotation ordering and permanent monitoring of unencrypted sessions.
Set the org-wide standard and ownership: who issues certificates, what the renewal automation is, what the exception process and expiry look like, and how the risk is reported.
## Why this is a migration Enforcement is a one-line change that fails closed: the moment the server rejects plaintext, every client that has not been migrated stops working, including the ones nobody remembered. The engineering work is in discovering and moving those clients, not in the flag. ## Step 1 -- measure what exists Every mainstream engine exposes, per active connection, whether the session is encrypted, along with the user and client address. Snapshot it repeatedly (not once -- batch jobs connect on schedules) and cross-reference the connection log. Build a list of client -> encrypted? -> owner. The usual surprises: - read replicas and the replication stream itself - backup, dump and restore tooling - schema-migration runners in CI - analytics/BI tools with their own connection settings - monitoring agents and health checks that connect frequently - humans with local clients and old connection strings ## Step 2 -- enable before enforcing Install the server key and certificate, keyed to the hostname clients actually dial, and leave the server accepting both. Nothing breaks; clients can now opt in. If a pooler fronts the database, it needs its own certificate *and* its own verified connection to the database -- two hops, two configurations. ## Step 3 -- migrate clients to verified TLS For each client, set the strongest verification mode and ship the CA bundle as part of the deployment artifact or secret mount. Going straight to full verification is preferable to a two-step 'encrypt now, verify later', because the second step never gets prioritised. Expect hostname mismatches where connection strings use IPs or internal aliases; the fix is the connection string, not a weaker mode. ## Step 4 -- flip enforcement on evidence Add a monitor that counts unencrypted sessions and alerts on any. When it has read zero across a full weekly cycle (so monthly jobs are the only residual risk -- check those explicitly), change the server's connection rules to reject non-TLS connections. Do it in a window with a tested rollback, and prefer to enforce per user/host first if the rule system allows, so a single stubborn client cannot force a full revert. ## Step 5 -- keep it working Enforced, verified TLS turns certificate lifecycle into an availability dependency: - **Automate renewal** and alert on approaching expiry with enough lead time for a human to act -- typically multiple weeks, and always more than one on-call rotation. - **Order CA rotations correctly**: distribute and trust the new CA on all clients *first*, then switch the server's certificate, then retire the old CA. Doing it in the other order is a self-inflicted outage. - **Cover replicas and tooling** in the same rotation, since they are the ones that silently break. - **Monitor the property, not the config.** Keep the 'unencrypted sessions' alert forever; a new service with a copy-pasted connection string will otherwise reintroduce plaintext quietly. - **Document the failure signatures** (expired certificate, untrusted issuer, hostname mismatch, clock skew) so an incident does not start with guesswork. ## A note on cost Symmetric encryption on modern CPUs is negligible; what costs is the handshake, which matters only for workloads that open connections constantly. That is an argument for connection pooling and session reuse rather than an argument against enforcement -- and it is the honest answer if an interviewer pushes on performance.
- How do you rotate the database's server certificate with no downtime for clients using full verification?Sequence it so trust always precedes use: first push the new issuing CA into every client's trust bundle and redeploy or reload them, confirming the old CA is still trusted too. Then install the new server certificate and reload the database so new connections use it. Existing sessions are unaffected because they are already established. Only once everything is on the new chain do you remove the old CA from the bundles.
- A single legacy client cannot be updated before the enforcement date. What are your options?Prefer scoped enforcement: if the connection-rule system allows per-user or per-source-address rules, require TLS everywhere and carve a narrow, logged, time-boxed exception for that one account and host. Failing that, front the legacy client with a local proxy that speaks plaintext on loopback only and TLS to the database. Both options must carry an expiry date and an owner, otherwise the exception becomes permanent.
saying these in an interview costs you the question
- Flipping enforcement without inventorying live connections first
- Forgetting replication, backup and CI clients
- Rotating the server certificate before clients trust the new CA
- Treating 'the config says TLS is enabled' as proof that clients use it
- Leaving verification at a weak mode after enforcement, so encryption is on but identity is unchecked