Class TlsTrusts
TlsTrust for a grpc+tls:// location.
The Java twin of Python's biopb.tensor._tls. A server on a private
LAN typically presents a self-signed or private-CA certificate that the JDK's
default trust store does not know, so the caller says how to trust it, in one
of three modes:
caPem-- trust exactly these PEM bytes (a private CA, or the server's own leaf). Never touches the network and never consults the pin store.expectedFingerprint-- fetch the presented leaf and require its SHA-256 to equal this, on every resolve: a wrong certificate is refused on the first connect, which trust-on-first-use cannot do. Also bypasses the pin store.- neither -- trust on first use, the SSH host-key model: the first
certificate seen for a
host:portis pinned in theTlsPinStoreand used as the anchor; a different one later is aTlsPinMismatchException. Protects against an attacker who arrives after pinning, not one already in the path at first connect.
Trust and hostname verification are separate checks. An anchor supplies the
first; the JDK still matches the dialed name against the certificate's
SANs, so a certificate that pins fine still fails every handshake if the
server never listed the name clients dial. When the anchor is the
certificate the server presents, that second check is redundant -- the
presented certificate must be the pinned one, so there is no "different but
validly-issued certificate" for a name check to exclude -- and a name the
certificate does list is substituted as the overrideHostname. A CA
anchor keeps the name check, which is load-bearing there. The substitution
never disables verification: the chain is still checked against the anchor.
One thing a plain FlightClient cannot give you: an expired anchor
fails every handshake with no reason the caller can read. TlsCertExpiredException is raised here instead, where the answer is known.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TlsTrustanchored(byte[] anchorPem) A trust that carriesanchorPemto a consumer to resolve for itself, as aSerializedTensor.tls_anchordoes.static TlsTrusttrustas something a client can use forlocation.static Stringfingerprint(byte[] pem) SHA-256 of a certificate's DER body, lowercase hex: the id a fingerprint names.static booleanisTlsLocation(org.apache.arrow.flight.Location location) Whetherlocationis agrpc+tls://address, so trust applies.static TlsTrustresolve(org.apache.arrow.flight.Location location, byte[] caPem, String expectedFingerprint, TlsPinStore pins) Resolve the trust forlocation.
-
Method Details
-
resolve
public static TlsTrust resolve(org.apache.arrow.flight.Location location, byte[] caPem, String expectedFingerprint, TlsPinStore pins) throws IOException Resolve the trust forlocation.- Parameters:
location- the server; a non-TLS location needs no trust and getsTlsTrust.NONEwith no networkcaPem- trust exactly these PEM bytes; wins over the other modesexpectedFingerprint- SHA-256 of the server's certificate DER, hex (colon-grouped or bare, any case)pins- where trust-on-first-use remembers pins; needed only when neithercaPemnorexpectedFingerprintis given- Throws:
TlsPinMismatchException- the server presents a certificate that contradicts the pin or the configured fingerprintTlsCertExpiredException- the anchor has expiredIllegalArgumentException- trust on first use was asked for with nopinsIOException- the server could not be reached to read its certificate
-
anchored
A trust that carriesanchorPemto a consumer to resolve for itself, as aSerializedTensor.tls_anchordoes. No network here, so the sender never has to reach the address the consumer will dial. Null or empty (the sender trusted the system store) is the system store again. -
concrete
trustas something a client can use forlocation.An
anchored(byte[])trust is the sender's decision about which certificate; the name check is this process's, because it depends on the name dialed here. When the anchor is the leaf the server presents, a name the certificate does not list is rescued with an override; a CA anchor keeps the SAN check. A probe that cannot run leaves no override, so a working connection never breaks here. -
isTlsLocation
public static boolean isTlsLocation(org.apache.arrow.flight.Location location) Whetherlocationis agrpc+tls://address, so trust applies. -
fingerprint
SHA-256 of a certificate's DER body, lowercase hex: the id a fingerprint names.
-