Interface MitmManager
- All Known Implementing Classes:
CertificateAuthorityMitmManager
HttpFilters.
The proxy calls the overloads that take a FlowContext; by default they delegate to
the ones without it. Override them to decide per client connection (by its authenticated user,
FlowContext.getClientDetails(), or its address, FlowContext.getClientAddress())
which CA impersonates servers, how servers are validated, or which client certificate is
presented to them. To keep a separate manager per tenant instead, see perConnection(java.util.function.Function<? super org.microproxy.FlowContext, ? extends org.microproxy.MitmManager>).
With HttpProxyServerBootstrap.withPoolSharedMitmConnections(boolean), a server connection made
for one client may serve another. A manager that overrides serverSslContext(String, int, FlowContext) or configureServerSocket(SSLSocket, FlowContext) may make different
decisions for different clients, so its server connections are kept per client connection
rather than pooled; managers chosen by forConnection(org.microproxy.FlowContext) only share pooled connections
with clients that were given the same manager.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionclientSslContextFor(HttpRequest connectRequest, SSLSession serverSslSession) TLS configuration presented to the client (proxy is TLS server), typically holding a certificate for the requested host signed by a CA the client trusts.default SSLContextclientSslContextFor(HttpRequest connectRequest, SSLSession serverSslSession, FlowContext flow) TLS configuration presented to the client connectionflow, e.g. with a certificate from that client's CA.default voidconfigureServerSocket(SSLSocket socket) Customizes the socket to the real server before its handshake.default voidconfigureServerSocket(SSLSocket socket, FlowContext flow) Customizes the socket to the real server for the client connectionflow.default MitmManagerforConnection(FlowContext flow) The manager that intercepts for the client connectionflow; this one by default.static MitmManagerperConnection(Function<? super FlowContext, ? extends MitmManager> choose) A manager that letschoosepick the manager for each client connection (seeforConnection(org.microproxy.FlowContext)), e.g. aCertificateAuthorityMitmManagerper tenant with its own CA and upstream trust store.serverSslContext(String peerHost, int peerPort) TLS configuration for the proxy's connection to the real server (proxy is TLS client).default SSLContextserverSslContext(String peerHost, int peerPort, FlowContext flow) TLS configuration for the proxy's connection to the real server, for the client connectionflow: the trust store servers are validated against, and the key the proxy authenticates with when a server asks for a client certificate.default X509TrustManagerserverTrustManager(String peerHost, int peerPort, FlowContext flow) How servers are validated where the proxy's TLS is not the JDK's: on QUIC connections to HTTP/3 servers (HttpProxyServerBootstrap.withHttp3Upstream(boolean)).default booleanshouldIntercept(ClientHello clientHello, FlowContext flow) Whether to intercept a TLS connection, once its client'sClientHellois known: return false to tunnel it untouched, so the client sees the real server's certificate.
-
Method Details
-
serverSslContext
TLS configuration for the proxy's connection to the real server (proxy is TLS client).- Parameters:
peerHost- the real server host namepeerPort- the real server port- Returns:
- the TLS context used towards the real server
-
serverSslContext
TLS configuration for the proxy's connection to the real server, for the client connectionflow: the trust store servers are validated against, and the key the proxy authenticates with when a server asks for a client certificate. Defaults toserverSslContext(String, int).- Parameters:
peerHost- the real server host namepeerPort- the real server portflow- aFullFlowContextnaming the server and the chained proxy, if any- Returns:
- the TLS context used towards the real server
-
serverTrustManager
How servers are validated where the proxy's TLS is not the JDK's: on QUIC connections to HTTP/3 servers (HttpProxyServerBootstrap.withHttp3Upstream(boolean)). The default is the trust manager ofserverSslContext(String, int, FlowContext)when that context came fromSslContexts(asCertificateAuthorityMitmManager's do), and null otherwise, which keeps the server on TCP, where the context applies. Server names are checked as HTTPS does, unless the trust manager trusts every server (SslContexts.trustAll()).- Parameters:
peerHost- the real server host namepeerPort- the real server portflow- aFullFlowContextnaming the server- Returns:
- the trust manager, or null to keep the server on TCP
-
clientSslContextFor
TLS configuration presented to the client (proxy is TLS server), typically holding a certificate for the requested host signed by a CA the client trusts.- Parameters:
connectRequest- the client's CONNECT requestserverSslSession- the established session with the real server- Returns:
- the TLS context presented to the client
-
clientSslContextFor
default SSLContext clientSslContextFor(HttpRequest connectRequest, SSLSession serverSslSession, FlowContext flow) TLS configuration presented to the client connectionflow, e.g. with a certificate from that client's CA. Defaults toclientSslContextFor(HttpRequest, SSLSession).- Parameters:
connectRequest- the CONNECT request naming the serverserverSslSession- the established session with the real server, ornullwhen intercepting without one (HttpFilters.proxyToServerAllowOfflineMitm())flow- the client connection's context- Returns:
- the TLS context presented to the client
-
configureServerSocket
Customizes the socket to the real server before its handshake. By default the proxy enables SNI and HTTPS host-name verification; override to relax that.- Parameters:
socket- the TLS socket to configure
-
configureServerSocket
Customizes the socket to the real server for the client connectionflow. Defaults toconfigureServerSocket(SSLSocket).- Parameters:
socket- the TLS socket to configureflow- aFullFlowContextnaming the server and the chained proxy, if any
-
shouldIntercept
Whether to intercept a TLS connection, once its client'sClientHellois known: return false to tunnel it untouched, so the client sees the real server's certificate. Decide by the server name the client asked for (ClientHello.sni()), its ALPN protocols, or the client (flow). Called on the manager chosen for the connection (forConnection(org.microproxy.FlowContext)), after the host rules (HttpProxyServerBootstrap.withIgnoreHosts(java.lang.String...),HttpProxyServerBootstrap.withAllowHosts(java.lang.String...)) and beforeHttpFilters.proxyToServerAllowMitm(ClientHello). True by default.- Parameters:
clientHello- the client's ClientHelloflow- the client connection's context;FlowContext.getClientHello()returnsclientHello- Returns:
- whether to intercept the connection
-
forConnection
The manager that intercepts for the client connectionflow; this one by default. The proxy asks once per client connection, when it is about to intercept the connection's first CONNECT (after proxy authentication, so the user is known), and uses the answer for every interception on that connection.nulldeclines: the connection's CONNECTs are tunnelled without interception.- Parameters:
flow- the client connection or exchange context- Returns:
- the manager to use for this client connection
-
perConnection
A manager that letschoosepick the manager for each client connection (seeforConnection(org.microproxy.FlowContext)), e.g. aCertificateAuthorityMitmManagerper tenant with its own CA and upstream trust store. Return the same instance for clients that may share pooled server connections; anullanswer declines interception.The returned manager only selects: its own methods throw
UnsupportedOperationException.- Parameters:
choose- the function selecting a manager for each client connection- Returns:
- the manager delegating selection to
choose
-