Class ImpersonatingMitmManager

java.lang.Object
com.shaft.capture.proxy.ImpersonatingMitmManager
All Implemented Interfaces:
org.littleshoot.proxy.MitmManager

public final class ImpersonatingMitmManager extends Object implements org.littleshoot.proxy.MitmManager
MitmManager that impersonates whatever host the mobile client is connecting to, using a fresh leaf certificate signed by a CaptureCertificateAuthority for every distinct hostname, so the proxy can terminate and inspect TLS traffic once the device trusts that CA.

One RSA leaf key pair is generated per ImpersonatingMitmManager instance and reused across every host it impersonates (only the certificate differs per host) -- generating a fresh RSA key pair per TLS handshake would be prohibitively slow, and every mainstream MITM-capable proxy (mitmproxy, Charles, LittleProxy's own littleproxy-mitm addon) uses this same shared-leaf-key, per-host-certificate approach.

The outbound (proxy -> real server) connection always uses the JVM's default trust manager, so this proxy never silently downgrades validation of the real upstream server's identity -- only the client-facing (device -> proxy) side is impersonated.

  • Constructor Details

    • ImpersonatingMitmManager

      public ImpersonatingMitmManager(CaptureCertificateAuthority certificateAuthority)
      Creates a MITM manager backed by the given certificate authority.
      Parameters:
      certificateAuthority - CA used to sign every per-host leaf certificate
  • Method Details

    • serverSslEngine

      public SSLEngine serverSslEngine(String peerHost, int peerPort)
      Specified by:
      serverSslEngine in interface org.littleshoot.proxy.MitmManager
    • serverSslEngine

      public SSLEngine serverSslEngine()
      Specified by:
      serverSslEngine in interface org.littleshoot.proxy.MitmManager
    • clientSslEngineFor

      public SSLEngine clientSslEngineFor(io.netty.handler.codec.http.HttpRequest httpRequest, SSLSession sslSession)
      Specified by:
      clientSslEngineFor in interface org.littleshoot.proxy.MitmManager