Skip to content

Commit 221aee2

Browse files
committed
Updated MITM documentation and LP version
1 parent b166613 commit 221aee2

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

mitm/README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
# MITM with LittleProxy
2-
The MITM module is a LittleProxy-compatible module that enables man-in-the-middle interception of HTTPS requests. Though it is developed and distributed with BrowserMob Proxy, it has no dependency on BMP and can be used in a LittleProxy-only environment. (The only transitive dependency of the MITM module is the Bouncy Castle encryption library.)
2+
The MITM module is a LittleProxy-compatible module that enables man-in-the-middle interception of HTTPS requests. MITM allows you to:
3+
- [Generate both RSA and EC private keys](#improving-performance-with-elliptic-curve-ec-cryptography) (EC provides a significant performance boost, ~50x faster than RSA)
4+
- [Use a custom Certificate Authority](#using-a-custom-certificate-authority) (e.g. a corporate CA) to sign impersonated certificates, or generate (and optionally save) a new CA on-the-fly
5+
- [Specify a custom trust store](#trusted-root-certificates-and-custom-trust-stores) on proxy-to-server connections, allowing the proxy to trust personal or corporate CAs
6+
- [Use OpenSSL](#openssl-support), improving performance over Java's built-in TLS implementation
37

4-
## Quick start
5-
The MITM module uses "sensible" default settings that should work for the vast majority of users without any further configuration.
8+
Though MITM is developed and distributed with BrowserMob Proxy, it has no dependency on BMP and can be used in a LittleProxy-only environment. The only additional dependency is the Bouncy Castle encryption library.
69

10+
## Quick start
711
### LittleProxy (without BrowserMob Proxy)
8-
**Note:** The MITM module requires Java 7
912

10-
To use MITM with standalone LittleProxy, add a dependency to the mitm module in your pom:
13+
To use MITM with standalone LittleProxy, add a dependency on the `mitm` module in your pom:
1114

1215
```xml
1316
<!-- existing LittleProxy dependency -->
1417
<dependency>
1518
<groupId>org.littleshoot</groupId>
1619
<artifactId>littleproxy</artifactId>
17-
<version>1.1.1</version>
20+
<version>1.1.2</version>
1821
</dependency>
1922

20-
<-- new dependency on the MITM module -->
23+
<!-- new dependency on the MITM module -->
2124
<dependency>
2225
<groupId>net.lightbody.bmp</groupId>
2326
<artifactId>mitm</artifactId>
@@ -37,7 +40,7 @@ The default implementation of `ImpersonatingMitmManager` will generate a new CA
3740
### BrowserMob Proxy
3841
The MITM module is enabled by default with BrowserMob Proxy. No additional steps are required to enable MITM with BrowserMob Proxy.
3942

40-
By default, BrowserMob Proxy will use the `ca-keystore-rsa.p12` file to load its CA Root Certificate and Private Key. The corresponding certificate file is `ca-certificate-rsa.cer`, which can be installed as a trusted Certification Authority in browsers or other HTTP clients to avoid HTTPS warnings when using BrowserMob Proxy.
43+
By default, BrowserMob Proxy will use the `ca-keystore-rsa.p12` file to load its CA Root Certificate and Private Key. The corresponding certificate file is `ca-certificate-rsa.cer`, which can be installed as a trusted Certificate Authority in browsers or other HTTP clients to avoid HTTPS warnings when using BrowserMob Proxy.
4144

4245
## Examples
4346
Several examples are available to help you get started:
@@ -49,7 +52,6 @@ Example File | Configuration
4952
[CustomCAKeyStoreExample.java](src/test/java/net/lightbody/bmp/mitm/example/CustomCAKeyStoreExample.java) and [CustomCAPemFileExample.java](src/test/java/net/lightbody/bmp/mitm/example/CustomCAPemFileExample.java) | Use an existing CA certificate and private key
5053
[EllipticCurveCAandServerExample.java](src/test/java/net/lightbody/bmp/mitm/example/EllipticCurveCAandServerExample.java) | Use EC cryptography when generating the CA private key and when impersonating server certificates
5154

52-
5355
## Generating and Saving Root Certificates
5456
By default, when using the MITM module with LittleProxy, the CA Root Certificate and Private Key are generated dynamically. The dynamically generated Root Certificate and Private Key can be saved for installation in a browser or later reuse by using the methods on the `RootCertificateGenerator` class. For example:
5557

@@ -76,7 +78,7 @@ By default, when using the MITM module with LittleProxy, the CA Root Certificate
7678
.withManInTheMiddle(mitmManager);
7779
```
7880

79-
## Using a Custom Certification Authority
81+
## Using a Custom Certificate Authority
8082
Whether you are using the MITM module with LittleProxy or BrowserMob Proxy, you can provide your own root certificate and private key to use when signing impersonated server certificates. To use a root certificate and private key from a key store (PKCS12 or JKS), use the `KeyStoreFileCertificateSource` class:
8183

8284
```java
@@ -99,7 +101,7 @@ Whether you are using the MITM module with LittleProxy or BrowserMob Proxy, you
99101

100102
You can also load the root certificate and private key from separate PEM-encoded files using the `PemFileCertificateSource` class, or create an implementation of `CertificateAndKeySource` that loads the certificate and private key from another source.
101103

102-
## Trusted Root Certificates
104+
## Trusted Root Certificates and Custom Trust Stores
103105
The MITM module trusts the Certificate Authorities in the JVM's default trust store, as well as a default list of trusted CAs derived from NSS/Firefox's list of trusted CAs (courtesy of the cURL team: https://curl.haxx.se/ca/cacert.pem).
104106

105107
To add your own CA to the list of root CAs trusted by the MITM module, use the `add()` methods in the `net.lightbody.bmp.mitm.TrustSource` class. Alternatively, it is possible to disable upstream server validation, but this is only recommended when testing. Examples:
@@ -124,14 +126,14 @@ To add your own CA to the list of root CAs trusted by the MITM module, use the `
124126
## Improving Performance with Elliptic Curve (EC) Cryptography
125127
By default, the certificates generated by the MITM module use RSA private keys for both impersonated server certificates and for generated CA root certificates. However, all modern browsers support Elliptic Curve Cryptography, which uses smaller key sizes. As a result, impersonated EC server certificates can be generated significantly faster (approximately 50x faster is common, typically <10ms per impersonated certificate).
126128

127-
Unforunately, due to a bug in Java's SSL handshake, EC keys cannot be used with RSA Certification Authorities (i.e. impersonated EC server certificates must be digitally signed by a CA's EC private key -- see https://bugs.openjdk.java.net/browse/JDK-8136442).
128-
129-
The MITM module's RootCertificateGenerator can be configured to generate an EC root certificate for use with EC server certificates. If you are using your own CA root certificate and private key, make sure to generate an EC private key if you intend to use impersonated EC server certificates.
129+
The MITM module's RootCertificateGenerator can be configured to generate an EC root certificate for use with EC server certificates. If you are using your own CA root certificate
130+
and private key, make sure to generate an EC private key if you intend to use impersonated EC server certificates. (Though it is possible to generate "hybrid"
131+
server certificates with an EC key signed by an RSA CA, they are uncommon, and not all clients support them. In particular, Java clients and servers [before 8u92 do not support hybrid certificates.](https://bugs.openjdk.java.net/browse/JDK-8136442))
130132
131133
To generate EC certificates for impersonated servers, set the `serverKeyGenerator` to `ECKeyGenerator` in ImpersonatingMitmManager. To generate an EC root certificate and private key, set the `keyGenerator` to `ECKeyGenerator` in RootCertificateGenerator:
132134
133135
```java
134-
// create a RootCertificateGenerator that generates EC Certification Authorities; you may also load your
136+
// create a RootCertificateGenerator that generates EC Certificate Authorities; you may also load your
135137
// own EC certificate and private key using any other CertificateAndKeySource implementation
136138
// (KeyStoreFileCertificateSource, PemFileCertificateSource, etc.).
137139
CertificateAndKeySource rootCertificateGenerator = RootCertificateGenerator.builder()
@@ -153,5 +155,10 @@ To generate EC certificates for impersonated servers, set the `serverKeyGenerato
153155
proxy.setMitmManager(mitmManager);
154156
```
155157
158+
## OpenSSL support
159+
The MITM module takes advantage of Netty's support for OpenSSL, allowing you to use OpenSSL instead of Java's built-in TLS implementation, which may provide
160+
significant performance benefits. The MITM module itself requires no additional configuration to use OpenSSL: all you need is an OpenSSL installation and a dependency on the `netty-tcnative` library for your platform.
161+
See Netty's OpenSSL instructions for details: http://netty.io/wiki/requirements-for-4.x.html#tls-with-openssl
162+
156163
## Acknowledgements
157164
The MITM module would not have been possible without the efforts of Frank Ganske, the Zed Attack Proxy, and Brad Hill. Thank you for all your excellent work!

mitm/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<dependency>
1616
<groupId>org.littleshoot</groupId>
1717
<artifactId>littleproxy</artifactId>
18-
<version>1.1.1</version>
18+
<version>1.1.2</version>
1919
<optional>true</optional>
2020
<exclusions>
2121
<exclusion>

mitm/src/main/java/net/lightbody/bmp/mitm/manager/ImpersonatingMitmManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private SslContext createImpersonatingSslContext(CertificateInfo certificateInfo
287287
// to impersonate the real upstream server, and will use the private key to encrypt the channel.
288288
KeyPair serverKeyPair = serverKeyGenerator.generate();
289289

290-
// get the CA root certificate and private key that will be used to sign the forced certificate
290+
// get the CA root certificate and private key that will be used to sign the forged certificate
291291
X509Certificate caRootCertificate = rootCertificate.get().getCertificate();
292292
PrivateKey caPrivateKey = rootCertificate.get().getPrivateKey();
293293
if (caRootCertificate == null || caPrivateKey == null) {

0 commit comments

Comments
 (0)