Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,14 @@ coverage breakdown and counts.
a connection string (hosts, credentials, `sasl_mechanism`/`client_intelligence`/
`protocol_version` params, and the server-auth TLS params below); timeouts and more
in issue #10
- ✅ **Server-authenticated TLS** (`setTls(...)` / `hotrods://`, issue #18) — wraps
every connection in a TLS session (OpenSSL). PEM trust (`ca_file`, empty = system
store), SNI, and host-name validation (default on); min TLS 1.2. URI keys:
`trust_store_file_name` (PEM CA), `sni_host_name`, `ssl_hostname_validation`.
Mutual TLS / keystore formats are deferred (issue #10)
- ✅ **TLS, incl. mutual TLS** (`setTls(...)` / `hotrods://`, issue #18) — wraps
every connection in a TLS session (OpenSSL); PEM material only. Server-auth: PEM
trust (`ca_file`, empty = system store), SNI, host-name validation (default on),
min TLS 1.2. Mutual TLS: PEM client cert + key. URI keys: `ca_file`,
`sni_host_name`, `ssl_hostname_validation`, `client_cert_file`, `client_key_file`,
`client_key_password`. Java keystore keys (`*_store_file_name`/`*_store_type`/…)
are rejected with a pointer to the PEM key; JKS/PKCS12 and cipher tuning deferred
(issue #10)
- ✅ **Multi-server seed list** (issue #12) — all hosts in the URI become seed
servers with startup *and* runtime failover (ops fall back to the seed list when
the connected server dies or no topology is known, e.g. in BASIC mode)
Expand Down Expand Up @@ -259,15 +262,21 @@ cache->connect();
// #12): connect() tries each in order, and ops fall back to the seed list when the
// connected server dies or no topology is known (e.g. BASIC mode). Credentials
// enable SCRAM, and sasl_mechanism/client_intelligence/protocol_version (Java
// "4.0"/"4.1" form) are honoured. hotrods:// enables server-auth TLS; the
// trust_store_file_name (PEM CA) / sni_host_name / ssl_hostname_validation params
// map to setTls(...). Userinfo and query values are percent-decoded (RFC 3986), so
// a reserved character in a password is written encoded — e.g. a password of p@ss
// is "...://admin:p%40ss@host". Timeouts, mutual TLS, and other parameters throw
// for now (see issue #10).
// "4.0"/"4.1" form) are honoured. hotrods:// enables TLS (PEM material only); the
// ca_file (PEM CA) / sni_host_name / ssl_hostname_validation params and the mutual-
// TLS client_cert_file / client_key_file / client_key_password params map to
// setTls(...). The Java keystore keys (trust_store_file_name, key_store_*, …) are
// rejected with a pointer to the PEM key. Userinfo and query values are percent-
// decoded (RFC 3986), so a reserved character in a password is written encoded —
// e.g. a password of p@ss is "...://admin:p%40ss@host". Timeouts and other
// parameters throw for now (see issue #10).
//
// // TLS from a URI (private CA):
// auto c = RemoteCache::fromUri("hotrods://cache:11222?trust_store_file_name=/etc/pki/ca.pem");
// // Server-auth TLS from a URI (private CA):
// auto c = RemoteCache::fromUri("hotrods://cache:11222?ca_file=/etc/pki/ca.pem");
// // Mutual TLS (client cert + key):
// auto m = RemoteCache::fromUri("hotrods://cache:11222?ca_file=/etc/pki/ca.pem"
// "&client_cert_file=/etc/pki/client.pem"
// "&client_key_file=/etc/pki/client-key.pem");
// // or programmatically:
// RemoteCache cache("cache", 11222);
// cache.setTls("/etc/pki/ca.pem"); // ca_file; empty = system trust store
Expand All @@ -285,9 +294,9 @@ cache->connect();
`replaceWithVersion`, `removeWithVersion`, `putIfAbsent`, `replace`, `containsKey`
- ✅ **Step 11 — Error handling** (shipped): ERROR response parsing, typed exception,
user-decided retry (keyed + keyless)
- ✅ **Server-authenticated TLS** (shipped, issue #18): `hotrods://` + `setTls(...)`
- ✅ **TLS, incl. mutual TLS** (shipped, issue #18): `hotrods://` + `setTls(...)`, PEM only
- **Step 12 — Bulk operations** (next): `GET_ALL`, `PUT_ALL`, `BULK_GET`
- Also: multiplexing benchmarks, mutual TLS (client cert/key, issue #10)
- Also: multiplexing benchmarks, non-SCRAM SASL + PKCS12/JKS keystores (issue #10)

## Project Structure

Expand Down
47 changes: 47 additions & 0 deletions docs/DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1271,3 +1271,50 @@ when the fixtures must actually change, and the regenerated files must then be
the committed fixtures); each run regenerates the whole chain together. Output dirs
overridable via `UNIT_DIR`/`INT_DIR` env vars (used to self-test without clobbering
the committed set).

## 2026-11-12 — PEM-honest TLS URI keys + mutual TLS (client cert/key)

**What:** Two linked changes to the TLS story.

1. **Mutual TLS (client certificate).** `TlsConfig` gains `cert_file` / `key_file` /
`key_password` (all PEM). `Connection::startTls` now loads a client cert chain +
private key (`SSL_CTX_use_certificate_chain_file` +
`SSL_CTX_use_PrivateKey_file` + `SSL_CTX_check_private_key`) and supplies the key
passphrase via `SSL_CTX_set_default_passwd_cb` so an encrypted key never blocks on
a terminal prompt. cert and key must be set together (fail-fast otherwise).

2. **PEM-honest URI keys + fail-fast on Java keystore keys.** The server-trust URI
key was renamed `trust_store_file_name` → **`ca_file`** (the name no longer
implies a JKS/PKCS12 container). New client-identity keys **`client_cert_file`**,
**`client_key_file`**, **`client_key_password`**. The Java keystore keys
(`trust_store_file_name`, `trust_store_type`, `trust_store_password`,
`key_store_file_name`, `key_store_type`, `key_store_password`, `key_alias`) are
now **rejected with a redirect message** pointing at the PEM equivalent, instead
of the old generic "not supported yet".

**Why it matters:** This client uses PEM, not Java keystores (decided for the #18
trust store). The shipped #18 key `trust_store_file_name` *accepted* a path but read
it as PEM — so a ported Java URI (`trust_store_file_name=truststore.jks`) would have
been silently misread. That was the one TLS URI footgun that failed silently rather
than loudly. Renaming to `ca_file` and making every keystore key throw with the fix
("use `ca_file=` / `client_cert_file=`+`client_key_file=` (PEM)") removes the
ambiguity: a ported Java URI now fails fast with the exact correction.

**Superseded:** the 2026-11-06 #18 decision that the URI carried
`trust_store_file_name` as a PEM CA path — that key is now rejected; use `ca_file`.
This is a deliberate backward-compat break, taken while #18 is still fresh.

**Gotcha discovered (TLS 1.3 mutual-TLS failure surfaces late):** when the server
requires a client cert and the client presents none, `SSL_connect()` *succeeds*
under TLS 1.3 — the server's "certificate required" alert only arrives on the first
I/O. (Under TLS 1.2 it fails at the handshake.) Production is unaffected because a
PING/SASL exchange immediately follows connect(); the unit test asserts the failure
across connect()+first-I/O rather than at connect() alone.

**Deferred still:** PKCS12/JKS keystore formats (PEM only, by decision), non-SCRAM
SASL, timeouts (issue #10). EXTERNAL SASL (which authenticates via the client cert)
is now unblocked by this change but not yet implemented.

**Keys still rejected (not keystore-related):** `use_ssl`, `ssl_protocol`,
`ssl_ciphers`, `ssl_named_groups`, `ssl_provider`, `ssl_context` — protocol/cipher
tuning deferred (issue #10).
85 changes: 53 additions & 32 deletions docs/STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
> If any other doc disagrees with this file, this file wins. Point-in-time
> snapshots live in [`archive/`](archive/) and are historical only.
>
> **Last updated:** 2026-11-09
> **Last updated:** 2026-11-12

---

Expand Down Expand Up @@ -41,9 +41,11 @@ _The 1–3 concrete things to do next. Keep this short and current._
(two `TODO`s in `src/operations/RemoteCache.cpp`).

_Recently shipped (detail in "Working and shipped" + [`DECISIONS.md`](DECISIONS.md)):
server-authenticated TLS for `hotrods://` (#18, 2026-11-06), multi-server seed
list + failover (#12), Hot Rod URI `fromUri` (#9), SASL/SCRAM auth, Step 11 error
handling + user-decided retry, Step 10 metadata/CAS._
mutual TLS (PEM client cert/key) + PEM-honest TLS URI keys (`ca_file`,
`client_cert_file`/`client_key_file`; Java keystore keys now rejected with a
redirect) (#18, 2026-11-12), server-authenticated TLS for `hotrods://` (#18,
2026-11-06), multi-server seed list + failover (#12), Hot Rod URI `fromUri` (#9),
SASL/SCRAM auth, Step 11 error handling + user-decided retry, Step 10 metadata/CAS._

---

Expand All @@ -59,19 +61,26 @@ pull from here next. Step numbers follow
`BULK_GET` (0x1F, iterator-style).

**Other known work (not roadmap steps):**
- [ ] **Mutual-TLS integration coverage** — client cert/key is unit-tested
(in-process OpenSSL server requiring a client cert) but not yet covered by the
Docker `TlsIntegrationTest`, which needs the Infinispan server configured to
require/verify client certs (extend `scripts/start_infinispan_tls.sh` +
`gen-test-certs.sh` already emits the unit client cert).
- [ ] **Benchmark the multiplexing path** — the async rewrite targets 5–10×
concurrent throughput; unmeasured so far.
- [ ] **Code cleanup:** read header "other params" when `paramCount > 0`
(`src/operations/RemoteCache.cpp:140,182`).
- [ ] **Hot Rod URI — deferred features (issue #10):** `connect_timeout`/
`socket_timeout`, non-SCRAM SASL (PLAIN/OAUTHBEARER `token`),
`protocol_version=AUTO`/3.x. Each drops its "unsupported" throw from
`HotRodURI::parse` once the capability lands. (Multi-server seed list — #12 —
and server-auth TLS — #18 — are already shipped; see "Working and shipped".)
- [ ] **Mutual TLS + TLS tuning (deferred part of #18/#10):** client cert/key
(`key_store_*`), Java keystore formats (JKS/PKCS12, `*_store_type`/password/
alias), and `ssl_protocol`/`ssl_ciphers`/`ssl_named_groups`/`ssl_provider`.
These URI keys are currently recognized and rejected with "not supported yet".
`socket_timeout`, non-SCRAM SASL (PLAIN/OAUTHBEARER `token`, EXTERNAL — now
unblocked by mutual TLS), `protocol_version=AUTO`/3.x. Each drops its
"unsupported" throw from `HotRodURI::parse` once the capability lands.
(Multi-server seed list — #12 — and TLS incl. mutual TLS — #18 — are already
shipped; see "Working and shipped".)
- [ ] **TLS keystore formats + tuning (deferred part of #18/#10):** Java keystore
formats (JKS/PKCS12, `*_store_file_name`/`*_store_type`/password/`key_alias`) —
this client is PEM-only, so these URI keys are rejected with a redirect to the
PEM keys (`ca_file`, `client_cert_file`/`client_key_file`). Also deferred:
`ssl_protocol`/`ssl_ciphers`/`ssl_named_groups`/`ssl_provider`/`use_ssl`.

**Longer horizon (Step 14+ advanced features):** transactions (XA), client
listeners/events, counters, Ickle queries, streaming ops (4.1+), multimap,
Expand All @@ -93,23 +102,32 @@ Rod URI `fromUri` (#9), multi-server seed list + failover (#12)._
`hotrod[s]://[user:pass@]host[:port][,host...][?k=v]` connection string (issue #9);
pure header-only parser `HotRodURI::parse` (`include/hotrod/HotRodURI.h`).
`hotrod://` and `hotrods://` (TLS) schemes, SCRAM via credentials,
`sasl_mechanism`/`client_intelligence`/`protocol_version` + the server-auth TLS
params (`trust_store_file_name`/`sni_host_name`/`ssl_hostname_validation`);
userinfo and query values are percent-decoded (java.net.URI parity); unsupported
schemes/params throw. timeouts/non-SCRAM/mutual-TLS deferred (issue #10)
- **Server-authenticated TLS (`hotrods://`, issue #18)** — `RemoteCache::setTls(...)`
`sasl_mechanism`/`client_intelligence`/`protocol_version` + the PEM TLS params
(`ca_file`/`sni_host_name`/`ssl_hostname_validation` and mutual-TLS
`client_cert_file`/`client_key_file`/`client_key_password`); userinfo and query
values are percent-decoded (java.net.URI parity); unsupported schemes/params and
the Java keystore keys throw. timeouts/non-SCRAM deferred (issue #10)
- **TLS incl. mutual TLS (`hotrods://`, issue #18)** — `RemoteCache::setTls(...)`
(and the `hotrods://` scheme) wrap every connection the client opens (seed +
topology-discovered) in a TLS session over OpenSSL. PEM trust material
(`ca_file`, empty = system store), SNI (`sni_host`, skipped for literal IPs),
and host-name validation (`hostname_validation`, default on; chain verification
always on). Min TLS 1.2. `include/hotrod/TlsConfig.h`; handshake in
`src/transport/Connection.cpp` (host-name validation via the `X509_VERIFY_PARAM`
API, so it builds clean on OpenSSL 1.1.0 through 4.0). Unit-tested against an in-process OpenSSL
server and end-to-end against a TLS-enabled Infinispan
topology-discovered) in a TLS session over OpenSSL. All certificate material is
**PEM** (not Java JKS/PKCS12). Server-auth: PEM trust material (`ca_file`, empty =
system store), SNI (`sni_host`, skipped for literal IPs), host-name validation
(`hostname_validation`, default on; chain verification always on), min TLS 1.2.
**Mutual TLS:** PEM client cert chain (`cert_file`) + private key (`key_file`) +
optional passphrase (`key_password`), loaded with a passwd callback so an
encrypted key never blocks on a prompt; cert/key must be set together.
`include/hotrod/TlsConfig.h`; handshake in `src/transport/Connection.cpp`
(host-name validation via the `X509_VERIFY_PARAM` API, so it builds clean on
OpenSSL 1.1.0 through 4.0). **URI keys:** `ca_file`, `sni_host_name`,
`ssl_hostname_validation`, `client_cert_file`, `client_key_file`,
`client_key_password`; the Java keystore keys (`trust_store_file_name`,
`key_store_*`, `*_store_type`/password, `key_alias`) are rejected with a redirect
to the PEM key. Unit-tested against an in-process OpenSSL server (server-auth +
mutual TLS) and end-to-end against a TLS-enabled Infinispan
(`tests/integration/TlsIntegrationTest.cpp`, Docker). A dropped connection is
SIGPIPE-safe per-connection (MSG_NOSIGNAL / SO_NOSIGPIPE / custom TLS BIO) — no
process-global signal change — so it surfaces as a thrown exception, not process
death. Mutual TLS / keystore formats deferred (#10)
death. JKS/PKCS12 keystore formats + cipher/protocol tuning deferred (#10)
- **Multi-server seed list + failover (`fromUri`, issue #12)** — all
comma-separated hosts become seed servers. **Startup failover:** `connect()`
tries each seed in order; all unreachable → one `HotRodClientException` listing
Expand Down Expand Up @@ -171,19 +189,22 @@ Rod URI `fromUri` (#9), multi-server seed list + failover (#12)._
that stalls a subprocess fails fast instead of hanging the whole CI job. See
[`DECISIONS.md`](DECISIONS.md).

**Test status (verified 2026-10-19):** **250 unit** + **96 integration** (20
suites), all passing. This is the one authoritative count — other docs describe
*what* is covered rather than repeating totals. Counts read from the built test
binaries via `--gtest_list_tests`, so they match what actually runs.
**Test status:** **266 unit** (verified 2026-11-12) + **96 integration** (20
suites, verified 2026-10-19), all passing. This is the one authoritative count —
other docs describe *what* is covered rather than repeating totals. Counts read
from the built test binaries via `--gtest_list_tests`, so they match what actually
runs. (The +16 unit tests since 2026-11-09 are the mutual-TLS handshake cases and
the PEM-honest URI-key parsing/redirect cases.)
- Unit (`./build/unit_tests`, <1s) — wire primitives/headers, consistent hashing,
server-selection/retry helpers, the SASL/SCRAM handshake, and the Hot Rod URI
parser.
server-selection/retry helpers, the SASL/SCRAM handshake, the TLS handshake
(server-auth + mutual TLS, in-process OpenSSL server), and the Hot Rod URI parser.
- Integration (`ctest`, spins up Docker Infinispan single-server + multi-node
clusters; also green on Linux CI) — CRUD + metadata/CAS, topology & hash-aware
routing, keyed/keyless retry (`RetryView`/ping), SASL/SCRAM against a secured
server, Hot Rod URI `fromUri`, and multi-server seed failover.
- Full run: `ctest --test-dir build --output-on-failure` → **100% pass, 21/21**
(1 unit + 20 integration suites) — verified end-to-end this session.
(1 unit + 20 integration suites) — last full end-to-end run 2026-10-19; unit
suite re-verified 2026-11-12 (266 pass) after the mutual-TLS/URI changes.
- **Concurrency validated (2026-09-25):** the concurrent suites pass 8/8
(incl. `ConcurrentWithFailover`), and a ThreadSanitizer run (`build-tsan/`)
reports **no races in production code** — slice-4's `stateMutex_`/`shared_ptr`
Expand Down
60 changes: 58 additions & 2 deletions documentation/topics/security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,61 @@ tested config):

=== TLS / mutual TLS

Transport encryption (TLS/SSL) is **not yet implemented**. See `docs/STATUS.md`
for the current roadmap.
Transport encryption (TLS/SSL) is supported over OpenSSL. All certificate
material is **PEM** — Java keystore formats (JKS/PKCS12) are not supported.

Enable it with the `hotrods://` URI scheme or `RemoteCache::setTls(...)`; every
connection the client opens (the seed connection and every topology-discovered
cluster member) is then wrapped in a TLS session (minimum TLS 1.2).

**Server-authenticated TLS** verifies the server's certificate chain (always on)
and, by default, that the certificate matches the host name:

[source,cpp]
----
// URI form (private CA):
auto c = RemoteCache::fromUri("hotrods://cache:11222?ca_file=/etc/pki/ca.pem");

// Programmatic form (empty ca_file = system/default trust store):
RemoteCache cache("cache", 11222);
cache.setTls("/etc/pki/ca.pem");
----

**Mutual TLS** additionally presents a client certificate. Supply a PEM client
cert chain and its private key (and a passphrase if the key is encrypted):

[source,cpp]
----
auto c = RemoteCache::fromUri(
"hotrods://cache:11222"
"?ca_file=/etc/pki/ca.pem"
"&client_cert_file=/etc/pki/client.pem"
"&client_key_file=/etc/pki/client-key.pem");

// Or programmatically:
TlsConfig tls;
tls.enabled = true;
tls.ca_file = "/etc/pki/ca.pem";
tls.cert_file = "/etc/pki/client.pem";
tls.key_file = "/etc/pki/client-key.pem";
// tls.key_password = "..."; // only if the key is encrypted
cache.setTls(tls);
----

.TLS URI query keys
[cols="1,2",options="header"]
|===
| Key | Meaning
| `ca_file` | PEM CA bundle to verify the server; empty = system trust store
| `sni_host_name` | SNI server name (skipped for literal IP addresses)
| `ssl_hostname_validation` | `true` (default) / `false` — host-name match toggle
| `client_cert_file` | PEM client certificate chain (mutual TLS)
| `client_key_file` | PEM client private key matching `client_cert_file`
| `client_key_password` | passphrase for an encrypted `client_key_file`
|===

NOTE: The Java keystore keys (`trust_store_file_name`, `key_store_file_name`,
`*_store_type`/`*_store_password`, `key_alias`) are rejected — this client uses
PEM. Use `ca_file` for trust and `client_cert_file` + `client_key_file` for the
client identity. Protocol/cipher tuning (`ssl_protocol`, `ssl_ciphers`, …) is not
yet supported (issue #10). See `docs/STATUS.md` for the current roadmap.
Loading
Loading