Package org.microproxy.tls
Class BrowserProfile
java.lang.Object
org.microproxy.tls.BrowserProfile
What one browser looks like to a server, as one thing to give the proxy: its TLS ClientHello,
its HTTP/2 connection preface and request framing, its QUIC and HTTP/3 connections (
Http3Options.Builder.upstreamProfile), and its request headers.
BrowserProfile chrome = BrowserProfile.chrome156();
HttpProxyServer proxy = MicroProxy.bootstrap()
.withManInTheMiddle(new CertificateAuthorityMitmManager(ca, chrome.sslContext(null)))
.withFiltersSource(chrome.filtersSource(true))
.start();
The context's sockets carry the HTTP/2 profile (FingerprintSslContext.Builder.attach(java.lang.Object)),
so HTTP/2 connections over them open as the browser's do without Http2Options.Builder.upstreamProfile; different servers can get different
browsers by returning different contexts from a MitmManager.
-
Method Summary
Modifier and TypeMethodDescriptionvoidapplyHeaders(HttpHeaders headers, boolean replaceUserAgent) Gives a request the browser's headers, in the browser's order: the browser'suser-agentin place of the client's whenreplaceUserAgentis set, or when the client sent none; the browser's headers the client did not send, exceptaccept-encoding, since a client that did not ask for an encoding could not read a body in it; novia, which says a proxy is there. The headers the browser sends come first, in its order; the client's others follow in theirs.static CertificateDecompressorDecompresses certificate chains (RFC 8879) with Brotli, zlib and, when thezstd-decodermodule is on the class path, zstd; each bounded to 1 MiB of output.static BrowserProfileChrome 156 on macOS, as captured from 156.0.8078.48:BrowserProfiles.chrome156(),Http2ClientProfile.chrome156(), and the headers of a navigation, in Chrome's order.filtersSource(boolean replaceUserAgent) Filters thatapply the browser's headersto every request on its way to the server.static BrowserProfileFirefox 159 on macOS, as captured from 159.0:BrowserProfiles.firefox159(),Http2ClientProfile.firefox159(), its QUIC and HTTP/3 connections (QuicClientProfile.firefox159(),Http3ClientProfile.firefox159()), and the headers of a navigation, in Firefox's order.Returns the HTTP/2 profile.Returns the HTTP/3 profile, or null if it has none.name()Returns the profile's name, such aschrome-156.Returns the QUIC client profile: its QUIC hello, transport parameters and Initial packets; null if it has none.Returns the browser's request headers, in its order.sslContext(X509TrustManager trustManager) A client context with the browser's TLS fingerprint, whose sockets carry its HTTP/2 profile, that decompresses certificates with Brotli, zlib and (when thezstd-decodermodule is on the class path) zstd.sslContext(X509TrustManager trustManager, EchConfigProvider ech) sslContext(X509TrustManager), encrypting the ClientHello (RFC 9849) to servers whose ECHConfigListechgives; to the others, and withechnull, the browser's GREASE ECH alone, as a browser sends when it has no ECHConfig.Returns the TLS ClientHello profile.toString()
-
Method Details
-
chrome156
Chrome 156 on macOS, as captured from 156.0.8078.48:BrowserProfiles.chrome156(),Http2ClientProfile.chrome156(), and the headers of a navigation, in Chrome's order. The capture was of headless Chrome, whose User-Agent saysHeadlessChrome; the profile's saysChrome, as a browser window's does.- Returns:
- the profile
-
firefox159
Firefox 159 on macOS, as captured from 159.0:BrowserProfiles.firefox159(),Http2ClientProfile.firefox159(), its QUIC and HTTP/3 connections (QuicClientProfile.firefox159(),Http3ClientProfile.firefox159()), and the headers of a navigation, in Firefox's order.- Returns:
- the profile
-
name
Returns the profile's name, such aschrome-156.- Returns:
- the profile's name, such as
chrome-156
-
tlsProfile
Returns the TLS ClientHello profile.- Returns:
- the TLS ClientHello profile
-
http2Profile
Returns the HTTP/2 profile.- Returns:
- the HTTP/2 profile
-
quicProfile
Returns the QUIC client profile: its QUIC hello, transport parameters and Initial packets; null if it has none.- Returns:
- the QUIC client profile: its QUIC hello, transport parameters and Initial packets; null if it has none
-
http3Profile
Returns the HTTP/3 profile, or null if it has none.- Returns:
- the HTTP/3 profile, or null if it has none
-
requestHeaders
Returns the browser's request headers, in its order.- Returns:
- the browser's request headers, in its order
-
sslContext
A client context with the browser's TLS fingerprint, whose sockets carry its HTTP/2 profile, that decompresses certificates with Brotli, zlib and (when thezstd-decodermodule is on the class path) zstd.- Parameters:
trustManager- the servers to trust, or null for the JDK's default trust store- Returns:
- the context
-
sslContext
sslContext(X509TrustManager), encrypting the ClientHello (RFC 9849) to servers whose ECHConfigListechgives; to the others, and withechnull, the browser's GREASE ECH alone, as a browser sends when it has no ECHConfig. No DNS lookups are made here:echdecides where configs come from (such as the server's DNS HTTPS record, from the resolver the deployment trusts).- Parameters:
trustManager- the servers to trust, or null for the JDK's default trust storeech- the source of servers' ECHConfigLists, or null for none- Returns:
- the context
-
certificateDecompressor
Decompresses certificate chains (RFC 8879) with Brotli, zlib and, when thezstd-decodermodule is on the class path, zstd; each bounded to 1 MiB of output.- Returns:
- the decompressor
-
applyHeaders
Gives a request the browser's headers, in the browser's order:- the browser's
user-agentin place of the client's whenreplaceUserAgentis set, or when the client sent none; - the browser's headers the client did not send, except
accept-encoding, since a client that did not ask for an encoding could not read a body in it; - no
via, which says a proxy is there.
- Parameters:
headers- the request's headers, changed in placereplaceUserAgent- whether the browser's User-Agent replaces the client's
- the browser's
-
filtersSource
Filters thatapply the browser's headersto every request on its way to the server.- Parameters:
replaceUserAgent- whether the browser's User-Agent replaces the client's- Returns:
- the filters' source
-
toString
-