Package org.microproxy
Record Class ClientHello
java.lang.Object
java.lang.Record
org.microproxy.ClientHello
- Record Components:
sni- the host name the client asked for (Server Name Indication), ornullwhen it sent none, or one that is not a valid host namealpnProtocols- the application protocols the client offered (ALPN), in its order of preference, decoded as ISO-8859-1; empty without the extensionversions- the TLS versions the client offered, as wire values (0x0304is TLS 1.3): those of thesupported_versionsextension, or else the message's legacy versioncipherSuites- the cipher suites the client offered, as wire valuesextensionTypes- the types of the extensions the client sent, in orderraw- the handshake message: its type (1), 3-byte length and body, without the TLS record headers it arrived in
public record ClientHello(String sni, List<String> alpnProtocols, List<Integer> versions, List<Integer> cipherSuites, List<Integer> extensionTypes, byte[] raw)
extends Record
A client's TLS
ClientHello, the first message of a handshake, as the proxy read it before
deciding whether to intercept a connection: after a CONNECT is accepted, and first thing
on a connection to a transparent listener.
The proxy reads it without consuming it: the same bytes then start the handshake the proxy
completes itself, or are relayed to the server when the connection is tunnelled.
Filters see it in HttpFilters.proxyToServerAllowMitm(ClientHello), MITM managers in
MitmManager.shouldIntercept(ClientHello, FlowContext), and anything holding the client
connection's FlowContext through FlowContext.getClientHello().
Values are as the client sent them, GREASE values (RFC 8701) included, except for sni(), which is only set for a single, well-formed host name.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealpnProtocolsrecord component.Returns the value of thecipherSuitesrecord component.booleanIndicates whether some other object is "equal to" this one.Returns the value of theextensionTypesrecord component.inthashCode()Returns a hash code value for this object.httpAlpnProtocols(boolean http2) The client's ALPN protocols that the proxy can speak over TLS:h2(whenwithHttp2is set),http/1.1andhttp/1.0, in the client's order.static booleanisGrease(int value) Whether a value is a GREASE value (RFC 8701), which clients add to lists of cipher suites, extensions, versions and ALPN protocols to keep servers tolerant of unknown values.booleanoffersAlpn(String protocol) Whether the client offeredprotocolthrough ALPN.byte[]raw()Returns a copy of the handshake message bytes.sni()Returns the value of thesnirecord component.toString()Returns a string representation of this record class.The offered TLS versions by name ("TLSv1.3","TLSv1.2", ...), as the JDK names them, without GREASE and unknown values.versions()Returns the value of theversionsrecord component.
-
Field Details
-
H2
The ALPN identifier of HTTP/2 over TLS.- See Also:
-
HTTP_1_1
The ALPN identifier of HTTP/1.1.- See Also:
-
HTTP_1_0
The ALPN identifier of HTTP/1.0.- See Also:
-
-
Constructor Details
-
ClientHello
public ClientHello(String sni, List<String> alpnProtocols, List<Integer> versions, List<Integer> cipherSuites, List<Integer> extensionTypes, byte[] raw) Creates a ClientHello, copying the lists and the message bytes.- Parameters:
sni- the requested host name, ornullalpnProtocols- the offered application protocolsversions- the offered TLS versions, as wire valuescipherSuites- the offered cipher suites, as wire valuesextensionTypes- the types of the extensions sentraw- the handshake message, without record headers- Throws:
NullPointerException- if a list orrawis null
-
-
Method Details
-
raw
public byte[] raw()Returns a copy of the handshake message bytes.- Returns:
- a copy of the handshake message bytes
-
versionNames
The offered TLS versions by name ("TLSv1.3","TLSv1.2", ...), as the JDK names them, without GREASE and unknown values.- Returns:
- the offered TLS versions by name, in the client's order
-
offersAlpn
Whether the client offeredprotocolthrough ALPN.- Parameters:
protocol- an ALPN identifier, such asH2- Returns:
- whether the client offered it
-
isGrease
public static boolean isGrease(int value) Whether a value is a GREASE value (RFC 8701), which clients add to lists of cipher suites, extensions, versions and ALPN protocols to keep servers tolerant of unknown values.- Parameters:
value- a two-byte wire value- Returns:
- whether
valueis one of the reserved0x?A?Avalues
-
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). -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. -
httpAlpnProtocols
The client's ALPN protocols that the proxy can speak over TLS:h2(whenwithHttp2is set),http/1.1andhttp/1.0, in the client's order.- Parameters:
http2- whether HTTP/2 may be included- Returns:
- the HTTP protocols the client offered, possibly empty
-
sni
Returns the value of thesnirecord component.- Returns:
- the value of the
snirecord component
-
alpnProtocols
Returns the value of thealpnProtocolsrecord component.- Returns:
- the value of the
alpnProtocolsrecord component
-
versions
Returns the value of theversionsrecord component.- Returns:
- the value of the
versionsrecord component
-
cipherSuites
Returns the value of thecipherSuitesrecord component.- Returns:
- the value of the
cipherSuitesrecord component
-
extensionTypes
Returns the value of theextensionTypesrecord component.- Returns:
- the value of the
extensionTypesrecord component
-