Package org.microproxy
Record Class TlsServerIdentity
java.lang.Object
java.lang.Record
org.microproxy.TlsServerIdentity
- Record Components:
serverName- the host name sent as SNI, or null for the default; never an IP address (SNI carries host names only)verificationHost- the host name or IP address the certificate must be valid for, or null for the server name
Who the proxy expects at the other end of a TLS connection to a server, when that is not simply
the request's host: the server name it sends in the ClientHello (SNI, RFC 6066 section 3) and
the host name the server's certificate is verified against (HTTPS endpoint identification, RFC
9110 section 4.3.4).
HttpFilters.proxyToServerTlsIdentity(java.lang.String) returns one for requests whose
connection goes somewhere other than the name they are for: a reverse-proxy route or a chained
setup that dials an IP address or an internal load balancer, while the service behind it
presents a certificate for its public name.
A null component keeps the default: the server name is the request's host (or, for an
intercepted CONNECT to an IP address, the server name the client sent), and the
verification host is the server name. Setting the server name alone thus verifies the
certificate against that name too; setting the verification host alone keeps the default SNI.
The identity is part of what keeps server connections apart: a connection made with one identity is never reused, pooled or coalesced (HTTP/2, RFC 9113 section 9.1.1) for a request with another.
-
Constructor Summary
ConstructorsConstructorDescriptionTlsServerIdentity(String serverName, String verificationHost) Checks and normalizes the names: lower case, without a trailing dot. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static TlsServerIdentityAn identity whose server name and verification host are bothserverName.static TlsServerIdentityAn identity with the given server name and verification host.Returns the value of theserverNamerecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theverificationHostrecord component.
-
Constructor Details
-
TlsServerIdentity
Checks and normalizes the names: lower case, without a trailing dot.- Parameters:
serverName- the host name sent as SNI, or null for the defaultverificationHost- the host the certificate must be valid for, or null for the server name- Throws:
IllegalArgumentException- ifserverNameis not a valid SNI host name, a component is blank, or both are null
-
-
Method Details
-
of
An identity whose server name and verification host are bothserverName.- Parameters:
serverName- the host name sent as SNI and that the certificate must be valid for- Returns:
- the identity
-
of
An identity with the given server name and verification host.- Parameters:
serverName- the host name sent as SNI, or null for the defaultverificationHost- the host the certificate must be valid for, or null for the server name- Returns:
- the identity
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
serverName
Returns the value of theserverNamerecord component.- Returns:
- the value of the
serverNamerecord component
-
verificationHost
Returns the value of theverificationHostrecord component.- Returns:
- the value of the
verificationHostrecord component
-