You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mitm/README.md
+22-15Lines changed: 22 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,26 @@
1
1
# 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
3
7
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.
6
9
10
+
## Quick start
7
11
### LittleProxy (without BrowserMob Proxy)
8
-
**Note:** The MITM module requires Java 7
9
12
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:
11
14
12
15
```xml
13
16
<!-- existing LittleProxy dependency -->
14
17
<dependency>
15
18
<groupId>org.littleshoot</groupId>
16
19
<artifactId>littleproxy</artifactId>
17
-
<version>1.1.1</version>
20
+
<version>1.1.2</version>
18
21
</dependency>
19
22
20
-
<-- new dependency on the MITM module -->
23
+
<!-- new dependency on the MITM module -->
21
24
<dependency>
22
25
<groupId>net.lightbody.bmp</groupId>
23
26
<artifactId>mitm</artifactId>
@@ -37,7 +40,7 @@ The default implementation of `ImpersonatingMitmManager` will generate a new CA
37
40
### BrowserMob Proxy
38
41
The MITM module is enabled by default with BrowserMob Proxy. No additional steps are required to enable MITM with BrowserMob Proxy.
39
42
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.
41
44
42
45
## Examples
43
46
Several examples are available to help you get started:
@@ -49,7 +52,6 @@ Example File | Configuration
49
52
[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
50
53
[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
51
54
52
-
53
55
## Generating and Saving Root Certificates
54
56
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:
55
57
@@ -76,7 +78,7 @@ By default, when using the MITM module with LittleProxy, the CA Root Certificate
76
78
.withManInTheMiddle(mitmManager);
77
79
```
78
80
79
-
## Using a CustomCertificationAuthority
81
+
## Using a CustomCertificateAuthority
80
82
Whether you are using the MITM module with LittleProxy or BrowserMobProxy, 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:
81
83
82
84
```java
@@ -99,7 +101,7 @@ Whether you are using the MITM module with LittleProxy or BrowserMob Proxy, you
99
101
100
102
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.
101
103
102
-
## TrustedRootCertificates
104
+
## TrustedRootCertificates and CustomTrustStores
103
105
TheMITM module trusts the CertificateAuthorities 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).
104
106
105
107
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 `
124
126
## ImprovingPerformance with EllipticCurve (EC) Cryptography
125
127
Bydefault, the certificates generated by the MITM module use RSAprivate keys for both impersonated server certificates and for generated CA root certificates. However, all modern browsers support EllipticCurveCryptography, 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).
126
128
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 ECprivate key -- see https://bugs.openjdk.java.net/browse/JDK-8136442).
128
-
129
-
TheMITM 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
+
TheMITM 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))
130
132
131
133
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:
132
134
133
135
```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
135
137
// own EC certificate and private key using any other CertificateAndKeySource implementation
@@ -153,5 +155,10 @@ To generate EC certificates for impersonated servers, set the `serverKeyGenerato
153
155
proxy.setMitmManager(mitmManager);
154
156
```
155
157
158
+
## OpenSSL support
159
+
The MITM module takes advantage of Netty's support forOpenSSL, 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
+
156
163
## Acknowledgements
157
164
TheMITM module would not have been possible without the efforts of FrankGanske, the ZedAttackProxy, and BradHill. Thank you for all your excellent work!
0 commit comments