Skip to content

feat: server-authenticated TLS for hotrods:// (issue #18) - #19

Merged
rigazilla merged 6 commits into
mainfrom
feat/tls-server-auth-issue-18
Nov 9, 2026
Merged

rigazilla merged 6 commits into
mainfrom
feat/tls-server-auth-issue-18

Conversation

@rigazilla

Copy link
Copy Markdown
Member

Closes #18.

Summary

Adds server-authenticated TLS so hotrods:// works, over OpenSSL with PEM certs
(first slice of #18; mutual TLS / keystore formats remain deferred under #10).

  • RemoteCache::setTls(...) and the hotrods:// scheme wrap every connection
    the client opens (seed + topology-discovered) in a TLS session.
  • 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.
  • SIGPIPE-safe per connection (MSG_NOSIGNAL / SO_NOSIGPIPE / custom TLS BIO) —
    no process-global signal change — so a dropped connection surfaces as a thrown
    exception, not process death.
  • include/hotrod/TlsConfig.h; handshake in src/transport/Connection.cpp.

Tests

  • Unit-tested against an in-process OpenSSL server.
  • End-to-end Docker integration suite against a TLS-enabled Infinispan
    (tests/integration/TlsIntegrationTest.cpp).
  • Full suite green: 100% passed, 0 failed / 22 suites.

Also in this branch (separate commit)

test: force --pull always … — a test-infra fix unrelated to the TLS code: the
integration suites run quay.io/infinispan/server:latest, but Docker reused a
stale cached tag, so a server predating the REST v3 API kept running and the
cluster/REST probes 404'd. Pins the pull behaviour (pull_policy: always in the
cluster compose; docker run --pull always in the single-node scripts); the test
code is unchanged. See docs/DECISIONS.md (2026-11-09).

🤖 Generated with Claude Code

rigazilla and others added 6 commits November 6, 2026 18:15
Wrap client connections in a TLS session over OpenSSL (server-auth only,
PEM trust material). The hotrods:// URI scheme no longer throws; TLS applies
to every connection the client opens (seed + topology-discovered).

- TlsConfig value type + RemoteCache::setTls(...) (mirrors setAuthentication),
  pushed down through MultiplexedConnection to Connection at the same build
  sites as auth/protocol/intelligence.
- Connection::startTls(): TLS_client_method, min TLS 1.2, PEM ca_file (empty =
  system trust store), SSL_VERIFY_PEER always, SNI (skipped for literal IPs),
  host-name match via SSL_set1_host (toggle: hostname_validation, default on;
  chain verification unconditional). send/receive route through SSL_write/read.
  Quiet shutdown on teardown to avoid SIGPIPE writing close_notify to a dead peer.
- HotRodURI: hotrods:// enables TLS; recognizes the three Java-named keys that
  map onto TlsConfig (trust_store_file_name -> ca_file [PEM], sni_host_name,
  ssl_hostname_validation). Other Java TLS keys (mutual TLS / keystore /
  cipher tuning) are rejected "not supported yet"; TLS params on hotrod:// error.
- OpenSSL::SSL link is now live (was dead weight next to libcrypto).
- Tests: TlsConnectionTest drives the real handshake against an in-process
  OpenSSL echo server with PEM fixtures (SAN=test.local); trusted/untrusted CA
  and host-name match on/off. HotRodURITest covers the URI surface. 260 unit
  tests green.

Mutual TLS, keystore formats, and cipher/protocol tuning remain deferred (#10).

Docs: STATUS (shipped + remaining), DECISIONS (dated rationale, supersedes the
OpenSSL::SSL "dead weight" aside), README (feature + URI/setTls usage).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
End-to-end coverage against a real TLS-enabled Infinispan, mirroring the auth
suite. New test-configs/infinispan-tls.xml (Hot Rod endpoint with a PKCS12
server identity, no SASL), scripts/start_infinispan_tls.sh, and PEM/PKCS12
fixtures under test-configs/tls/ (CA + server cert, SAN localhost/127.0.0.1).

TlsIntegrationTest cases (all green against :latest):
- programmatic setTls(ca) -> connect + PUT/GET round-trip over TLS;
- hotrods://?trust_store_file_name=<ca> -> same round-trip;
- untrusted anchor (empty CA -> system store) -> connect() throws;
- host-name mismatch: validation on -> throws; off -> round-trip (chain still verified).

Notes captured in DECISIONS: the mounted keystore must be world-readable (the
in-container user can't read a 0600 :ro mount), and keystore-password is
deprecated in favor of password. Also surfaced a library-robustness follow-up:
a dropped TLS connection can raise SIGPIPE on a client write; both test mains
install SIG_IGN, and whether the library should be SIGPIPE-safe by default is
left as an open item.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…IGN)

A write onto a dropped TLS peer raised SIGPIPE, whose default disposition kills
the process (the integration suite died with exit 141). The Java client avoids
this only because the JVM sets SIGPIPE to SIG_IGN process-wide at startup — a
runtime/process-owner decision. This client is a guest in someone else's process
and must not flip global signal state (it would, e.g., break a CLI tool relying
on shell-pipeline SIGPIPE semantics). So suppress SIGPIPE per connection instead:

- plain send() uses MSG_NOSIGNAL on Linux (HOTROD_SEND_FLAGS);
- macOS/BSD set SO_NOSIGPIPE on the socket (covers OpenSSL writes too);
- the Linux TLS path routes all OpenSSL socket I/O through a custom MSG_NOSIGNAL
  BIO, covering SSL_write plus the writes SSL_connect/SSL_read trigger internally;
- Windows is unaffected (no SIGPIPE) and keeps SSL_set_fd.

Observably identical to Java (dropped connection -> thrown exception, process
survives) but with a narrower blast radius. The integration test main() no longer
installs SIG_IGN, so it proves the library is self-sufficient (exit 0, not 141);
the unit test keeps SIG_IGN only to guard its in-process echo server thread.
260 unit tests + 5 TLS integration tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…est server

The cluster and single-server integration suites bring up
quay.io/infinispan/server:latest, but Docker reuses a locally cached tag
instead of pulling. An 8-month-old cached :latest (pre-rest/v3) kept being
reused, so the REST probes 404'd — clusters appeared to never form and
owner/size lookups came back empty.

Pin the pull behaviour (not the API): pull_policy: always on all four nodes
in docker-compose-cluster.yml, and docker run --pull always in the
start_infinispan_{noauth,auth,tls}.sh scripts. The test code is unchanged and
still correctly uses the rest/v3 API. See docs/DECISIONS.md (2026-11-09).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fedora CI builds with OpenSSL 4.0 and -Werror=deprecated-declarations, where
SSL_set_hostflags / SSL_set1_host are deprecated, breaking the build (Ubuntu and
Windows, on older OpenSSL, were unaffected).

Configure host-name validation on the SSL's X509_VERIFY_PARAM directly via
SSL_get0_param + X509_VERIFY_PARAM_set_hostflags / X509_VERIFY_PARAM_set1_host.
These are the functions the deprecated wrappers alias, so behaviour is identical,
and they exist since OpenSSL 1.1.0 — builds clean on 1.1.0 through 4.0.

See docs/DECISIONS.md (2026-11-09).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…xtures

The TLS test certificates were hand-made with openssl and committed as opaque
blobs (unit set in tests/fixtures/tls/, integration set in test-configs/tls/) with
no way to regenerate them. Add a documented, self-contained generator that
reproduces both sets with the same properties (subjects, SANs, RSA-2048/SHA-256,
~100-year validity).

The committed fixtures are left unchanged (they do not expire); the script is for
when they must actually change (new SAN, mutual-TLS client certs for #10,
rotation). Output dirs are overridable via UNIT_DIR/INT_DIR for self-testing.

See docs/DECISIONS.md (2026-11-09).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rigazilla
rigazilla merged commit 4c1eb19 into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TLS transport: server-authenticated TLS (PEM) for hotrods://

1 participant